-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: PeriodIndex speed up #14931
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
PERF: PeriodIndex speed up #14931
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ def dt64arr_to_periodarr(data, freq, tz): | |
|
||
# --- Period index sketch | ||
|
||
|
||
_DIFFERENT_FREQ_INDEX = period._DIFFERENT_FREQ_INDEX | ||
|
||
|
||
|
@@ -305,7 +306,7 @@ def _simple_new(cls, values, name=None, freq=None, **kwargs): | |
if (len(values) > 0 and is_float_dtype(values)): | ||
raise TypeError("PeriodIndex can't take floats") | ||
else: | ||
return PeriodIndex(values, name=name, freq=freq, **kwargs) | ||
return cls(values, name=name, freq=freq, **kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave this here, maybe causing the ndim test sto fail There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not what's causing the test failure (it could only be different if |
||
|
||
values = np.array(values, dtype='int64', copy=False) | ||
|
||
|
@@ -326,6 +327,8 @@ def _shallow_copy(self, values=None, **kwargs): | |
if kwargs.get('freq') is None: | ||
# freq must be provided | ||
kwargs['freq'] = self.freq | ||
if values is None: | ||
values = self._values | ||
return super(PeriodIndex, self)._shallow_copy(values=values, **kwargs) | ||
|
||
def _coerce_scalar_to_index(self, item): | ||
|
@@ -356,9 +359,8 @@ def __contains__(self, key): | |
def asi8(self): | ||
return self._values.view('i8') | ||
|
||
@property | ||
@cache_readonly | ||
def _int64index(self): | ||
# do not cache, same as .asi8 | ||
return Int64Index(self.asi8, name=self.name, fastpath=True) | ||
|
||
@property | ||
|
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.
Ideally this would be parameterized with Index type. For another day though.