8000 REF: use asi8 instead of _data in PeriodArray by jbrockmendel · Pull Request #23416 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

REF: use asi8 instead of _data in PeriodArray #23416

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 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use validation methods to simplify __new__
  • Loading branch information
jbrockmendel committed Oct 30, 2018
commit 73cec9b683a7607443cd46a387d804498a31d0a5
19 changes: 2 additions & 17 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from pandas.core.algorithms import unique1d
from pandas.core.dtypes.dtypes import PeriodDtype
import pandas.core.arrays.datetimelike as dtl
from pandas.core.arrays.period import PeriodArray, period_array
from pandas.core.base import _shared_docs
from pandas.core.indexes.base import _index_shared_docs, ensure_index
Expand Down Expand Up @@ -200,27 +201,11 @@ def __new__(cls, data=None, ordinal=None, freq=None, start=None, end=None,

if data is None and ordinal is None:
# range-based.
if periods is not None:
if is_float(periods):
periods = int(periods)

elif not is_integer(periods):
msg = 'periods must be a number, got {periods}'
raise TypeError(msg.format(periods=periods))

Copy link
Member Author

Choose a reason for hiding this comment

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

This is done within PeriodArray._generate_range

data, freq = PeriodArray._generate_range(start, end, periods,
freq, fields)
data = PeriodArray(data, freq=freq)
else:
if freq is None and dtype is not None:
freq = PeriodDtype(dtype).freq
elif freq and dtype:
freq = PeriodDtype(freq).freq
dtype = PeriodDtype(dtype).freq

if freq != dtype:
msg = "specified freq and dtype are different"
raise IncompatibleFrequency(msg)
freq = dtl.validate_dtype_freq(dtype, freq)

# PeriodIndex allow PeriodIndex(period_index, freq=different)
# Let's not encourage that kind of behavior in PeriodArray.
Expand Down
0