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

Different API with rolling function #14

Closed
s-celles opened this issue Jun 21, 2019 · 5 comments
Closed

Different API with rolling function #14

s-celles opened this issue Jun 21, 2019 · 5 comments

Comments

@s-celles
Copy link

Hello,

I wonder if

mean(rolling(data, windowsize))

or with piping operator

rolling(data, windowsize) |> mean

couldn't be an interesting API

What is your opinion?

Kind regards

@JeffreySarnoff
Copy link
Owner

What would be involved?

@s-celles
Copy link
Author

s-celles commented Jun 21, 2019

it could reduce the number of exported functions and provide an API quite similar to Python Pandas and have a kind of object oriented API (by using multiple dispatch)

See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html

An other feature that could be provide could be to also have expanding functions.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.expanding.html#pandas.DataFrame.expanding

For example we have cumsum and cumprod in Base but not neither cummax nor cummin JuliaLang/julia#1649

So a similar approach could be done with expanding functions
See JuliaLang/julia#1649 (comment)

@s-celles s-celles changed the title Different API Different API with rolling function Jun 21, 2019
@JeffreySarnoff
Copy link
Owner

JeffreySarnoff commented Jun 21, 2019

your mean(rolling(data, windowsize)) is my rolling(mean, data, windowsize)
rollmean(data, windowsize) is just a convenience for rolling(mean, data, windowsize)

It wouldn't really reduce the number of exported functions .. I could simply not export the rollmean etc and force the user to use rolling(mean, data, windowsize) .. also, more importantly, I would have to overload mean and all the others which may cause interoperability issues with other packages down the line (or today).

FYI the general approach was (no disrespect to Pandas) inspired by functions and libs I had used with R.

Adding cummax cummin etc seems like a good idea.

@s-celles
Copy link
Author

cummin and cummax have been deprecated in favor of accumulate

https://github.com/JuliaLang/julia/blob/480703b9d770f82202b8a6daf0b3414fc7e9fad9/HISTORY.md

JuliaLang/julia#18931

@JeffreySarnoff
Copy link
Owner

ok -- thank you for the note

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

No branches or pull requests

2 participants