-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
REF: Make PeriodArray an ExtensionArray #22862
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
Changes from 1 commit
eaadcbc
a05928a
3c0d9ee
63fc3fa
7d5d71c
e5caac6
c194407
eb4506b
1b9fd7a
0fa0ed1
3247ea8
c162cdd
611d378
fb2ff82
25a380f
1b2c4ec
d04293e
eacad39
70cd3b8
9b22889
87d289a
6369c7f
01551f0
0437940
42ab137
298390f
23e5cfc
9d17fd2
959cd72
b66f617
5669675
2c0311c
012be1c
c3a96d0
67faabc
ff7c06c
c2d57bd
fbde770
1c4bbe7
b395c90
d68a5c5
0c7b704
d26d3d2
e4babea
7f6c144
b4aa4ca
6a70131
9aa077c
411738c
8e0fb69
6d98e85
6d9e150
4899479
634def1
1f18452
2f92b22
23f232c
dd3b8cd
1a7c360
87ecb64
0bde329
2d85a82
438e6b5
a9456fd
ac05365
36ed547
4652ca7
a047a1b
a4a30d7
1441ae6
8003808
5f43753
1c13d0f
bae6b3d
f422cf0
0229d74
aa40cf4
29085e1
00ffddf
e81fa9c
0c8925f
96204a1
82930f7
8d24582
1fc7744
6cd428c
21693e0
b65ffad
1f438e3
f3928fb
089f8ab
700650a
452c229
e3e0e57
78751c2
203d561
eb1c67d
e08aa79
c1ee04b
827e563
ca4a7fd
ed185c0
b3407ac
a4011eb
fc1ca3c
1b1841f
b3b315a
3ab4176
8102475
8c329eb
78d4960
4e3d914
5e4aaa7
7f77563
f88d6f7
7aa78ba
2d737f8
833899a
236b49c
8230347
bf33a57
738acfe
032ec02
77e389a
61031d7
a094b3d
ace4856
fc6a1c7
900afcf
0baa3e9
f95106e
e57e24a
ce1c970
a7e1216
2548d6a
02e3863
1997cff
af2d1de
64f5778
4151510
ac9bd41
5462bd7
c1c6428
7ab2736
bd6f966
8068daf
5691506
575d61a
4065bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,10 +279,15 @@ def _simple_new(cls, values, name=None, freq=None, **kwargs): | |
# Data | ||
@property | ||
def _ndarray_values(self): | ||
return self.values.values | ||
return self._data._ndarray_values | ||
|
||
@property | ||
def values(self): | ||
# TODO: Discussion on what this should be. | ||
return self._data | ||
|
||
@property | ||
def _values(self): | ||
return self._data | ||
|
||
@property | ||
|
@@ -307,7 +312,7 @@ def freq(self, value): | |
def _shallow_copy(self, values=None, **kwargs): | ||
# TODO: simplify, figure out type of values | ||
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. So from some printing in the tests, some exploration on what is passed here:
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. This is basically what motivated #23095. Even if the solution is unwanted there, I think it identifies all the extant places where unwanted types are currently passed to _shallow_copy |
||
if values is None: | ||
values = self._values | ||
values = self._data | ||
|
||
if isinstance(values, type(self)): | ||
values = values.values | ||
|
@@ -912,7 +917,7 @@ def _create_comparison_method(cls, op): | |
""" | ||
# TODO(DatetimeArray): move to base class. | ||
def wrapper(self, other): | ||
return op(self.values, other) | ||
return op(self._data, other) | ||
|
||
wrapper.__doc__ = op.__doc__ | ||
wrapper.__name__ = '__{}__'.format(op.__name__) | ||
|
@@ -948,7 +953,7 @@ def item(self): | |
# TODO(DatetimeArray): remove | ||
# override to use _item | ||
try: | ||
return self.values._item() | ||
return self._data._item() | ||
except IndexError: | ||
# copy numpy's message here because Py26 raises an IndexError | ||
raise ValueError('can only convert an array of size 1 to a ' | ||
|
@@ -960,7 +965,7 @@ def data(self): | |
warnings.warn("{obj}.data is deprecated and will be removed " | ||
"in a future version".format(obj=type(self).__name__), | ||
FutureWarning, stacklevel=2) | ||
return np.asarray(self.values).data | ||
return np.asarray(self._data).data | ||
|
||
@property | ||
def base(self): | ||
|
@@ -970,7 +975,7 @@ def base(self): | |
warnings.warn("{obj}.base is deprecated and will be removed " | ||
"in a future version".format(obj=type(self).__name__), | ||
FutureWarning, stacklevel=2) | ||
return np.asarray(self.values) | ||
return np.asarray(self._data) | ||
|
||
|
||
PeriodIndex._add_comparison_ops() | ||
|
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.
what is this used for?
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.
To support
PeriodIndex.item
, while avoiding unnecessary methods on PeriodArray.But I see now it would be clearer to just implement this logic in `PeriodIndex itself.