Skip to content
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

Add rolling.rank() same as pandas #8677

Open
Mirac-Le opened this issue Jan 28, 2024 · 4 comments
Open

Add rolling.rank() same as pandas #8677

Mirac-Le opened this issue Jan 28, 2024 · 4 comments

Comments

@Mirac-Le
Copy link

Is your feature request related to a problem?

Dear xarray maintainers,

I would like to express my heartfelt gratitude for the significant optimizations your xarray library has brought to my project. Xarray combines the speed of numpy with the highly customizable parameters of pandas. The extensive parameters in the rolling module have allowed me to achieve functionality similar to pandas more efficiently.

I am wondering if it would be possible to incorporate a ranking method for rolling windows, including the ability to specify parameters such as pct, similar to the pandas rolling.rank function. Your consideration of this feature would be greatly appreciated.

Once again, thank you for your contributions!
rolling

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Copy link

welcome bot commented Jan 28, 2024

Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!

@Mirac-Le
Copy link
Author

It would be even better if skewness and kurtosis functions could be added. Thanks a lot!

@max-sixty
Copy link
Collaborator

Someone would need to look more, but possibly this is hooking up bottleneck's move_rank in the same way bottleneck's other move_ functions.

@Mirac-Le
Copy link
Author

Hi, max-sixty. Thanks for your reply!
I have conducted tests on pandas, xarray, and bottleneck using a randomly generated 5000*5000 ndarray containing NaN values. I found that xarray and bottleneck exhibit similar speeds, with xarray being slightly faster (based on tests involving rolling sum, mean, etc. Their results are the same. Bottleneck's move_rank does not provide a pct parameter). I noticed a statement in the xarray documentation: "rolling window aggregations are faster and use less memory when bottleneck is installed".
If it's possible to perform rolling rank, skew, kurt, and other related calculations using xarray's native functions, that would be fantastic. I've become reliant on xarray since I first learned about it and use it, and it has provided significant convenience for my project. It is fast, and the parameters are similar to those in pandas. Thanks to all the maintainers for providing us with such a great library.
I'm looking forward to the emergence of new features and your reply. Thanks again for taking the time!
:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants