You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can see that groupby.tshift is inconsistent with other groupby transformations. It retains the groupby column, and more importantly reordered the data.
Following this thinking I would expect the returned data to behave more like
>>>df.groupby("A").tshift(1, "D") # this is actually the result of df.tshift(1, "D").drop(columns='A')B2020-01-021.02020-01-032.02020-01-04NaN2020-01-053.02020-01-063.02020-01-07NaN2020-01-084.0
However, if we are to make groupby.tshift consistent with other groupby transformation like the above, this makes it no different from df.tshift(1, "D").drop(columns='A')', and groupby` has lost its meaning here.
Perhaps we should just deprecate groupby.tshift entirely? I know #11631 discussed about deprecating tshift, but that has been stalled for a long time.
The text was updated successfully, but these errors were encountered:
I discovered this while trying to tackle issue #32344, where @ryankarlos mentioned
groupby.transform('tshift', ...)
seems to behave incorrectly.However, before we can address #32344, we probably need to address this.
We can see that
groupby.tshift
is inconsistent with other groupby transformations. It retains the groupby column, and more importantly reordered the data.Since 0.25 we have had deliberate effort to make all groupby transformations consistent, see https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.25.0.html#dataframe-groupby-ffill-bfill-no-longer-return-group-labels
Following this thinking I would expect the returned data to behave more like
However, if we are to make
groupby.tshift
consistent with other groupby transformation like the above, this makes it no different fromdf.tshift(1, "D").drop(columns='A')', and
groupby` has lost its meaning here.Perhaps we should just deprecate
groupby.tshift
entirely? I know #11631 discussed about deprecatingtshift
, but that has been stalled for a long time.The text was updated successfully, but these errors were encountered: