Skip to content

ENH: classmethods for pd.period_range & pd.date_range #12984

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

Closed
max-sixty opened this issue Apr 25, 2016 · 4 comments
Closed

ENH: classmethods for pd.period_range & pd.date_range #12984

max-sixty opened this issue Apr 25, 2016 · 4 comments
Labels

Comments

@max-sixty
Copy link
Contributor

Floating an idea: pd.PeriodIndex.from_range & pd.DatetimeIndex.from_range as classmethods to mirror pd.period_range & pd.date_range respectively. This encapsulates constructors on the class.

Also could have pd.DatetimeIndex.from_dataframe for #12967

@jreback
Copy link
Contributor

jreback commented Apr 25, 2016

@MaximilianR why? that's seems like more typing to me.

@max-sixty
Copy link
Contributor Author

why? that's seems like more typing to me.

For the encapsulation - i.e. the ways of creating an instance are all listed on the class. It's also a nice pythonic approach.

While I wouldn't think removing the existing methods would be worth the effort (and maybe that makes adding these new ones a non-starter), the approach of putting constructors on classes in future also helps to keep the pd. namespace cleaner

@jreback
Copy link
Contributor

jreback commented Apr 25, 2016

you realize that these are convenience functions that just call the constructor now (albeit with a default for the freq) Not sure why adding something is helpful here. It would just be another name.

@max-sixty
Copy link
Contributor Author

I didn't realize they were such a thin wrapper. Closing for now.

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

No branches or pull requests

2 participants