Skip to content

QST: Python pandas 1.3.5 to 1.4.0 breaking changes - Got array instead of string #49023

@voldardard

Description

@voldardard

Research

  • I have searched the [pandas] tag on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/73906430/python-pandas-1-3-5-to-1-4-0-breaking-changes-got-array-instead-of-string

Question about pandas

Hello !

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApplyApply, Aggregate, Transform, MapGroupbyRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions