Skip to content

API/DEPR: casting bool-indexer to slice in dt64/td64/period #36210

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
jbrockmendel opened this issue Sep 8, 2020 · 6 comments · Fixed by #36654
Closed

API/DEPR: casting bool-indexer to slice in dt64/td64/period #36210

jbrockmendel opened this issue Sep 8, 2020 · 6 comments · Fixed by #36654
Labels
API - Consistency Internal Consistency of API/Behavior API Design Deprecate Functionality to remove in pandas
Milestone

Comments

@jbrockmendel
Copy link
Member

We use special logic for dt64/td64/period dtypes that makes view/copy behavior different from other dtypes:

dti = pd.date_range("2016-01-01", periods=4, tz="US/Pacific")
key = np.array([True, True, False, False])

ser1 = pd.Series(dti._data)
ser2 = pd.Series(range(4))

res1 = ser1[key]
res2 = ser2[key]

>>> res1._values._data.base is None
False
>>> res2._values.base is None
True

cc @jorisvandenbossche IIRC you advocated not doing this special casing.

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member API - Consistency Internal Consistency of API/Behavior API Design Deprecate Functionality to remove in pandas and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 8, 2020
@jbrockmendel
Copy link
Member Author

cc @jorisvandenbossche i havent thought of any nice ways to deprecate this (s.t. we can say "do X to get the future behavior, do Y to get the old behavior"). thoughts?

@jorisvandenbossche
Copy link
Member

Hmm, I also can't think of any way to deprecate this ..
It could maybe be done within the more general copy/view discussion, but then it's not something on the short term.

I am inclined to say that in this case it might be fine to simply change (because it's a behaviour that only comes up in rare value-dependent cases, and when it happens can lead to silent bugs).

@jbrockmendel
Copy link
Member Author

I checked what happened if I remove this behavior: 26 test failures, all about a freq mismatch.

@jorisvandenbossche
Copy link
Member

Because the slice keeps the freq per definition, and when doing a mask it always looses the freq?

@jbrockmendel
Copy link
Member Author

That was my thought too, but when i tried patching get_getitem_freq to account for that it didnt help

@jbrockmendel
Copy link
Member Author

update: got it working, was patching incorrectly in one place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior API Design Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants