We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Groupby.shift
Say I have a MultiIndex Series as follows:
s = cudf.Series(range(4), index=cudf.MultiIndex.from_tuples([('a', 1), ('a', 2), ('b', 1), ('b', 2)], names=['f', 's']))
which looks like:
f s a 1 0 2 1 b 1 2 2 3 dtype: int64
I want to shift this Series down by the first index level:
s.groupby(level=0).shift(1)
but I get an error:
AttributeError: 'RangeIndex' object has no attribute '_names'
This should produce either
f s a 1 NaN 2 0.0 b 1 NaN 2 2.0 dtype: float64
or
f s a 2 0.0 b 2 2.0 dtype: float64
Right now, I can get my desired output by unstacking the Series, shifting it and then stacking it back:
s.to_frame().unstack('f').shift().rename(columns=lambda x: x[1]).stack()
which is very ugly. I would like cudf to extend groupby.shift to MultiIndex.
groupby.shift
The text was updated successfully, but these errors were encountered:
Thanks - this seems a bug with our implementation of .shift. Should be a relatively easy fix - we'll try to get to it ASAP!
.shift
Sorry, something went wrong.
Fix Series.groupby.shift with a MultiIndex (#15098)
4948aa2
closes #15087 closes #11259 (The typing annotation is incorrect, but I guess there needs to be a check somewhere to make `_copy_type_metadata` stricter) Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - Bradley Dice (https://github.com/bdice) URL: #15098
Successfully merging a pull request may close this issue.
Say I have a MultiIndex Series as follows:
which looks like:
I want to shift this Series down by the first index level:
but I get an error:
This should produce either
or
Right now, I can get my desired output by unstacking the Series, shifting it and then stacking it back:
which is very ugly. I would like cudf to extend
groupby.shift
to MultiIndex.The text was updated successfully, but these errors were encountered: