Skip to content

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

Merged
merged 21 commits into from
Aug 8, 2019
Merged

CLN: Assorted Cleanups #27791

merged 21 commits into from
Aug 8, 2019

Conversation

jbrockmendel
Copy link
Member

  • 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

@pep8speaks
Copy link

pep8speaks commented Aug 6, 2019

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

@gfyoung gfyoung added Clean Internals Related to non-user accessible pandas implementation labels Aug 7, 2019
def test_NaT_cast(self):
result = Series([np.nan]).astype("period[D]")
expected = Series([pd.NaT])
expected = Series([pd.NaT], dtype="period[D]")
Copy link
Member

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 ?

Copy link
Member Author

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

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a 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)
Copy link
Member

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)

Copy link
Member Author

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].

Copy link
Member

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 ?

Copy link
Member Author

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):
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

@jreback : I think you're referring to #27669, which should not be impacted by this.

Copy link
Contributor

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?

Copy link
Member Author

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

@jreback jreback added this to the 1.0 milestone Aug 8, 2019
@jreback jreback merged commit d320ef7 into pandas-dev:master Aug 8, 2019
@jreback
Copy link
Contributor

jreback commented Aug 8, 2019

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the eaprelim2 branch August 8, 2019 13:33
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants