Skip to content

ENH: PeriodIndex now has period dtype #13941

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
wants to merge 3 commits into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Aug 8, 2016

splitted dtype related part from #13755, to clarify the differences related to PeriodIndex

@sinhrks sinhrks added Dtype Conversions Unexpected or buggy dtype conversions API Design Period Period data type labels Aug 8, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Aug 8, 2016
@sinhrks sinhrks mentioned this pull request Aug 8, 2016
4 tasks
@max-sixty
Copy link
Contributor

Looks superb! Thanks @sinhrks

@sinhrks sinhrks force-pushed the period_dtype branch 2 times, most recently from f9740ed to af2def9 Compare August 8, 2016 22:42
``PeriodIndex`` now has ``period`` dtype
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``PeriodIndex`` now has its own ``period`` dtype. ``period`` dtype is a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

say pandas extension dtype

@codecov-io
Copy link

codecov-io commented Aug 9, 2016

Current coverage is 85.30% (diff: 92.80%)

Merging #13941 into master will increase coverage by 0.01%

@@             master     #13941   diff @@
==========================================
  Files           139        139          
  Lines         50241      50346   +105   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          42851      42947    +96   
- Misses         7390       7399     +9   
  Partials          0          0          

Powered by Codecov. Last update 5d791cc...a968782

@shoyer
Copy link
Member

shoyer commented Aug 9, 2016

What do you get when you write np.array(period_index) or period_index.values? Currently these give back arrays of integers, which IMO is pretty broken.

@jreback
Copy link
Contributor

jreback commented Aug 9, 2016

@shoyer yeah that should return an object array of Periods (similar to what a datetime tz does)

jreback pushed a commit that referenced this pull request Aug 10, 2016
removed unused / duplicated internal method
returning array-likes. Also added some tests to guarantee existing API
before fixing its dtype (see #13941).

Author: sinhrks <[email protected]>

Closes #13955 from sinhrks/object_array_cln and squashes the following commits:

a75a718 [sinhrks] CLN: Period cleanup related to array like meth
@sinhrks
Copy link
Member Author

sinhrks commented Aug 13, 2016

split .values change as #13988, as it can be handled separately.

@jorisvandenbossche jorisvandenbossche mentioned this pull request Aug 13, 2016
@sinhrks sinhrks force-pushed the period_dtype branch 3 times, most recently from 537b7e4 to e2b4564 Compare August 13, 2016 16:56
@jreback
Copy link
Contributor

jreback commented Aug 13, 2016

@sinhrks a couple of minor changes, but otherwise lgtm. period is currently broken as its int64 for its dtype. This makes things much more consistent (on the index side).

In [1]: pi = pd.PeriodIndex(['2016-08-01'], freq='D')
In [2]: pi
Out[2]: PeriodIndex(['2016-08-01'], dtype='int64', freq='D')
In [3]: pd.types.api.is_integer_dtype(pi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the current public entry point (although depends on outcome of discussion in #13634), I think pd.api.types.is_.. is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep.. @jorisvandenbossche right here

dtype similar to the timezone aware dtype (``datetime64[ns, tz]``).

The ``period`` dtype holds the ``freq`` attribute and is represented with
``period[freq]``, using :ref:`frequency strings <timeseries.offset_aliases>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add e.g. period[D] or period[M]

@jreback
Copy link
Contributor

jreback commented Aug 15, 2016

just some minor changes / perf checks. Getting the is_period_type to be fast in the common case is important. For datetime w/tz took me several tries to make this happen

.. _timeseries.timezone_series:

The ``period`` dtype holds the ``freq`` attribute and is represented with
``period[freq]`` like ``period[D]`` or ``period[D]``, using :ref:`frequency strings <timeseries.offset_aliases>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second period[D] should be a different example?

@jreback
Copy link
Contributor

jreback commented Aug 17, 2016

thanks @sinhrks nice change!

@sinhrks sinhrks deleted the period_dtype branch August 17, 2016 22:20
@sinhrks
Copy link
Member Author

sinhrks commented Aug 17, 2016

Thx for review. Because #14010 includes some period related tests, it'll broken on master. I'll send a fix soon.

jreback pushed a commit that referenced this pull request Aug 18, 2016
xref #13941.

Author: sinhrks <[email protected]>

Closes #14025 from sinhrks/test_coercion_period and squashes the following commits:

b873683 [sinhrks] TST: Fix test_coercion for period dtype
jreback pushed a commit that referenced this pull request Aug 24, 2016
split from #13941 (comment)

Author: sinhrks <[email protected]>

Closes #13988 from sinhrks/period_values and squashes the following commits:

d7637c9 [sinhrks] API: PeriodIndex.values now return array of Period objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Period Period data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants