-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Looks superb! Thanks @sinhrks |
f9740ed
to
af2def9
Compare
``PeriodIndex`` now has ``period`` dtype | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
``PeriodIndex`` now has its own ``period`` dtype. ``period`` dtype is a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
say pandas extension dtype
Current coverage is 85.30% (diff: 92.80%)@@ 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
|
What do you get when you write |
@shoyer yeah that should return an object array of Periods (similar to what a datetime tz does) |
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
split |
537b7e4
to
e2b4564
Compare
@sinhrks a couple of minor changes, but otherwise lgtm. period is currently broken as its |
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>`. |
There was a problem hiding this comment.
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]
just some minor changes / perf checks. Getting the |
.. _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>`. |
There was a problem hiding this comment.
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?
thanks @sinhrks nice change! |
Thx for review. Because #14010 includes some period related tests, it'll broken on master. I'll send a fix soon. |
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
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
git diff upstream/master | flake8 --diff
splitted
dtype
related part from #13755, to clarify the differences related toPeriodIndex