-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
WIP: DatetimeArray+TimedeltaArray #23415
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
Closed
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e7ecbf8
Implement concat_same_type, take
jbrockmendel e309ab9
implement from_sequence, from_factorized, values_for_factore, copy
jbrockmendel 423a357
rename DatetimeArrayMixin-->DatetimeArray
jbrockmendel 47689be
implement unique
jbrockmendel dc4a264
commit prelim some I can rebase
jbrockmendel f92843b
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
jbrockmendel 92923b2
update name
jbrockmendel 77e9a48
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
jbrockmendel 07d4d97
Merge branch 'master' of https://github.com/pandas-dev/pandas into dl…
jbrockmendel cd63892
update imports
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
implement from_sequence, from_factorized, values_for_factore, copy
- Loading branch information
commit e309ab94ef38c77136fef733613c600761899b99
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,10 @@ def asi8(self): | |
# ------------------------------------------------------------------ | ||
# Array-like Methods | ||
|
||
@property | ||
def nbytes(self): | ||
return self.asi8.nbytes | ||
|
||
@property | ||
def shape(self): | ||
return (len(self),) | ||
|
@@ -211,6 +215,31 @@ def astype(self, dtype, copy=True): | |
|
||
# ------------------------------------------------------------------ | ||
# ExtensionArray Interface | ||
# isna | ||
# __getitem__ | ||
# __len__ | ||
# nbytes | ||
# take | ||
# _concat_same_type | ||
# copy | ||
# _from_factorized | ||
# factorize / _values_for_factorize | ||
# _from_sequence | ||
# unique | ||
# | ||
# dtype | ||
# | ||
# dropna | ||
# | ||
#* _formatting_values | ||
#* fillna | ||
#* argsort / _values_for_argsort | ||
#* _reduce | ||
|
||
def unique(self): | ||
from pandas.core.algorithms import unique1d | ||
result = unique1d(self.asi8) | ||
return self._shallow_copy(result) | ||
|
||
def _validate_fill_value(self, fill_value): | ||
""" | ||
|
@@ -254,9 +283,36 @@ def _concat_same_type(cls, to_concat): | |
values = np.concatenate([x._data for x in to_concat]) | ||
return cls._simple_new(values, freq=freq) | ||
|
||
def copy(self, deep=False): | ||
# TODO: should `deep` determine whether we copy self.asi8? | ||
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. yes like
|
||
if is_datetime64tz_dtype(self): | ||
return type(self)(self.asi8.copy(), tz=self.tz, freq=self.freq) | ||
return type(self)(self.asi8.copy(), freq=self.freq) | ||
|
||
def _values_for_factorize(self): | ||
return self.asi8, iNaT | ||
|
||
@classmethod | ||
def _from_factorized(cls, values, original): | ||
if is_datetime64tz_dtype(original): | ||
return cls(values, tz=original.tz, freq=original.freq) | ||
return cls(values, freq=original.freq) | ||
|
||
@classmethod | ||
def _from_sequence(cls, scalars, dtype=None, copy=False): | ||
arr = np.asarray(scalars, dtype=object) | ||
if copy: | ||
arr = arr.copy() | ||
|
||
# If necessary this will infer tz from dtype | ||
return cls(arr, dtype=dtype) | ||
|
||
# ------------------------------------------------------------------ | ||
# Null Handling | ||
|
||
def isna(self): | ||
return self._isnan | ||
|
||
@property # NB: override with cache_readonly in immutable subclasses | ||
def _isnan(self): | ||
""" return if each value is nan""" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.