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]
Comment From: sinhrks
xref: #10718. We can fix PeriodIndex.dtype_str
when we have period
dtype.
Comment From: sinhrks
I'm working on this recently, and found we should to fix some dtype issues first (#12619 and #12758). - https://github.com/pydata/pandas/compare/master...sinhrks:periodblock2
Comment From: jreback
you might be better off sub-classing the Block from DatetimelikeBlcok
no?
Comment From: jorisvandenbossche
Going to make it a PeriodArray extension array