-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add Series.set_index #27058
New issue
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
Comments
You can do this in a chain now by converting the Series to DataFrame, using In [21]: ser.to_frame() \
...: .set_index(ser.index.floor('D')) \
...: .iloc[:, 0] \
...: .rolling('5D') \
...: .sum()
...:
Out[21]:
2001-01-01 0.0
2001-01-02 1.0
2001-01-03 3.0
Name: 0, dtype: float64 Perhaps there is a case for |
Thanks, you're right. I updated the OP. |
It turns out that the |
Related #21684
update: use
set_axis
.sometimes when writing a sequence of operation, you want to replace the index of the object you're working on. Say, quantizing the dates. I can't find the .method way of doing
ser.index= expr
So that I can't write something like
Things that don't solve this:
reindex
is aligning, so if your new index permutes the indexes, it isn't suitable.set_index
takes a column name, not an expression, and isn't available on series. update works for frames, though you must provide an arraylike, not a listlike.reindex_like
expects a PandasObject instead of a listlike, and is aligningreset_index
does not take a values argumentThe text was updated successfully, but these errors were encountered: