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

ENH: Add pd.to_period #14108

Closed
gfyoung opened this issue Aug 28, 2016 · 5 comments
Closed

ENH: Add pd.to_period #14108

gfyoung opened this issue Aug 28, 2016 · 5 comments
Labels

Comments

@gfyoung
Copy link
Member

gfyoung commented Aug 28, 2016

Would return Period or PeriodIndex, analogous to functions like to_datetime and to_timedelta.

xref #5886
xref #14048

cc @sinhrks

@gfyoung gfyoung changed the title ENH: Add pd.to_period ENH: Add pd.to_period Aug 28, 2016
@gfyoung gfyoung mentioned this issue Aug 28, 2016
3 tasks
@jreback jreback added this to the Next Major Release milestone Aug 28, 2016
@sinhrks
Copy link
Member

sinhrks commented Aug 29, 2016

If we follow the same policy as #8254, DatetimeIndex.to_period should be deprecated in favor of this.

@jorisvandenbossche
Copy link
Member

If we follow the same policy as #8254, DatetimeIndex.to_period should be deprecated in favor of this.

IMO that is not needed. The current Index.to_datetime was for parsing non-time values to datetime (wich is the core business of pd.to_datetime). Where DatetimeIndex/Timestamp.to_period and PeriodIndex/Period.to_timestamp are methods for converting between the different time representations.

@TomAugspurger
Copy link
Contributor

The PeriodArray PR is adding a period_array method for constructing a PeriodArray from a list-like of periods.

The only thing that won't handle is scalars. Is that OK? I think that case is already covered by pd.Period(scalar, freq).

@jorisvandenbossche
Copy link
Member

A to_period could also have a format argument to be able to parse datetime strings that are out of range for to_datetime.

@TomAugspurger
Copy link
Contributor

@jorisvandenbossche, do you have an example in mind?

In [4]: pd.core.arrays.period_array(['0001-01-01', '0001-01-02'], freq='D')
Out[4]:
<PeriodArray>
['0001-01-01', '0001-01-02']
Length: 2, dtype: period[D]

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

5 participants