Skip to content

CLN: remove kwargs from Index._simple_new #29604

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 2 commits into from
Nov 14, 2019

Conversation

topper-123
Copy link
Contributor

Removes kwargs from Index._simple_new.

The kwargs are actually ony used by DateTimeIndex.difference and TimeDeltaIndex.difference.

@jbrockmendel
Copy link
Member

nice

def difference(self, other, sort=None):
new_idx = super().difference(other, sort=sort)
new_idx.freq = None
return new_idx
Copy link
Member

Choose a reason for hiding this comment

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

could this be shared in one of the datetimelike classes?

Copy link
Contributor Author

@topper-123 topper-123 Nov 14, 2019

Choose a reason for hiding this comment

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

I don't think so: PeriodIndex doesn't allow freq=None and DatetimeIndexOpsMixin is shared with that`. Don't know if that's a bug in PeriodIndex or as intended, as I haven't worked much with datetime objects.

My motivation with this is getting kwargs out of a basic method and make child classes just build on that using super + the specific stuff. That is easier to reason about IMO.

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.

Small comment, looks good for the rest!

@@ -464,6 +464,11 @@ def _convert_for_op(self, value):
return _to_M8(value)
raise ValueError("Passed item and index have different timezone")

def difference(self, other, sort=None):
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a docstring here? (I think you can use one of the decorators to append Index.difference.__doc__)

(and same below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added.

@jreback jreback added this to the 1.0 milestone Nov 14, 2019
@topper-123 topper-123 force-pushed the Index._simple_new_kwargs branch from fe28788 to 2109eae Compare November 14, 2019 14:38
@jreback
Copy link
Contributor

jreback commented Nov 14, 2019

lgtm. merge on green.

@topper-123 topper-123 closed this Nov 14, 2019
@topper-123 topper-123 reopened this Nov 14, 2019
@topper-123 topper-123 merged commit 6a5c860 into pandas-dev:master Nov 14, 2019
@topper-123 topper-123 deleted the Index._simple_new_kwargs branch November 14, 2019 15:16
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants