【发布时间】:2022-12-27 14:50:24
【问题描述】:
I'm encountering an error with the update of pandas version from 1.3.5 to the major version 1.4.0. It is still happening on all subversion 1.4.2 and 1.4.4.
Here is my code:
print(df.T.to_dict().values())
df = df.reset_index().groupby(['startTime']).agg({
'startTime': np.unique,
'endTimes': lambda field: list(field),
'durationSplit': lambda field: list(field),
'split': lambda field: list(field),
})
print(df.T.to_dict().values())
With version 1.35. it print:
dict_values([{'startTime': '1970-01-01T10:30:00', 'endTimes': '1970-01-01T13:00:00', 'durationSplit': None, 'split': None}])
dict_values([{'startTime': '1970-01-01T10:30:00', 'endTimes': ['1970-01-01T13:00:00'], 'durationSplit': [None], 'split': [None]}])
With versions 1.4.0, 1.4.2, 1.4.4 (1.5.0 too) it print:
dict_values([{'startTime': '1970-01-01T10:30:00', 'endTimes': '1970-01-01T13:00:00', 'durationSplit': None, 'split': None}])
dict_values([{'startTime': array(['1970-01-01T10:30:00'], dtype=object), 'endTimes': ['1970-01-01T13:00:00'], 'durationSplit': [None], 'split': [None]}])
I cannot find any breaking change about that with pandas or found someone else with the same problem.
I only get a new warning here which say:
FutureWarning: Dropping invalid columns in SeriesGroupBy.agg is deprecated. In a future version, a TypeError will be raised. Before calling .agg, select only columns which should be valid for the function.
Do you have more information or can explain me what is going on ? or how can I do something similar differently :')
Thank you by advance for your help !
【问题讨论】: