-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Assorted Cleanups #27791
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
CLN: Assorted Cleanups #27791
Conversation
jbrockmendel
commented
Aug 6, 2019
- make PTA/DTA strftime() return ndarray instead of Index
- fix a xfailed Series[Period] test
- avoid imports of Index subclass in arrays.categorical and arrays.datetimelike
- some typing
Hello @jbrockmendel! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-08-07 00:56:59 UTC |
def test_NaT_cast(self): | ||
result = Series([np.nan]).astype("period[D]") | ||
expected = Series([pd.NaT]) | ||
expected = Series([pd.NaT], dtype="period[D]") |
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 changing a test, no? Why are we dropping the xfail
?
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.
IIUC the xfail was from a time before dtype="period[D]"
was recognized
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.
Nice clean-up, added few comments
|
||
other = TimedeltaIndex(other) | ||
other = TimedeltaArray._from_sequence(other) |
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.
if other
is a timedelta64 dtype, the _from_sequence
is not needed (and rather confusing the reader IMO)
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.
it is timedelta64, but not necessarily timedelta64[ns].
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.
@jbrockmendel I think we should avoid using _from_sequence
for that in our code base. Maybe array(.., dtype='timedelta64[ns])
instead ?
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.
why do you want to avoid _from_sequence?
if is_categorical(values): | ||
values = CategoricalIndex(values) | ||
# The CategoricalIndex level we want to build has the same categories | ||
if is_categorical_dtype(values): |
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.
IIRC @jschendel didn't we just change this to make a perf fix? is this change compat with that
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.
I put together this version by looking at the old version and taking out the non-executed paths. So this shouldn't take a hti
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.
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.
OT: we might be able to remove is_categorical entirely?
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.
Yah we should. Will need to be deprecated since its in the API
thanks @jbrockmendel |