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

API/ENH: allow Period to be a first-class type via a PeriodBlockinternal type #7964

Closed
jreback opened this issue Aug 8, 2014 · 4 comments
Closed
Labels
API Design Enhancement Internals Related to non-user accessible pandas implementation Period Period data type

Comments

@jreback
Copy link
Contributor

jreback commented Aug 8, 2014

Instead of having a represenation of an array of Period objects (object dtype) in a Series/DataFrame. Allow an internal type of PeriodBlock to represent, similary to DatetimeBlock.

Here is a usecase. The following would be very simple if to_period(...) returned a PeriodIndex

In [59]: df = DataFrame({'date' : pd.date_range('20130101 00:01:00',periods=5,freq='61s')})

In [60]: df
Out[60]: 
                 date
0 2013-01-01 00:01:00
1 2013-01-01 00:02:01
2 2013-01-01 00:03:02
3 2013-01-01 00:04:03
4 2013-01-01 00:05:04

In [61]: df.date.dt.to_period('T')                   
Out[61]: 
0    2013-01-01 00:01
1    2013-01-01 00:02
2    2013-01-01 00:03
3    2013-01-01 00:04
4    2013-01-01 00:05
dtype: object

In [62]: pd.Series(pd.PeriodIndex(df.date.dt.to_period('T')+1).to_timestamp())
Out[62]: 
0   2013-01-01 00:02:00
1   2013-01-01 00:03:00
2   2013-01-01 00:04:00
3   2013-01-01 00:05:00
4   2013-01-01 00:06:00
dtype: datetime64[ns]
@jreback jreback added this to the 0.15.1 milestone Aug 8, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@sinhrks
Copy link
Member

sinhrks commented Aug 8, 2015

xref: #10718. We can fix PeriodIndex.dtype_str when we have period dtype.

@sinhrks
Copy link
Member

sinhrks commented Apr 6, 2016

I'm working on this recently, and found we should to fix some dtype issues first (#12619 and #12758).

@sinhrks sinhrks modified the milestones: 0.19.0, Next Major Release Apr 6, 2016
@jreback
Copy link
Contributor Author

jreback commented Apr 6, 2016

you might be better off sub-classing the Block from DatetimelikeBlcok no?

@jorisvandenbossche
Copy link
Member

Going to make it a PeriodArray extension array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Internals Related to non-user accessible pandas implementation Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants