Skip to content

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

@jreback

Description

@jreback

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] 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions