Skip to content
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

DEPR: Series.__setitem__ with Float64Index falling back to positional #42215

Merged
merged 6 commits into from Jul 4, 2021

Conversation

jbrockmendel
Copy link
Member

@jreback jreback added Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Jun 25, 2021
@jreback jreback added this to the 1.4 milestone Jun 25, 2021
@jreback
Copy link
Contributor

jreback commented Jun 25, 2021

@jorisvandenbossche ok here?

@jorisvandenbossche
Copy link
Member

Looks good to me.

Can you add an explicit test (eg with the example series from the issue) that checks the warning is raised if the key (as float) is not present and does not raise a warning when it is present (that case that already works correctly label-based right now)?

There are no other index types that can end up in this case and trigger the warning?

@jbrockmendel
Copy link
Member Author

Can you add an explicit test (eg with the example series from the issue) that checks the warning is raised if the key (as float) is not present and does not raise a warning when it is present (that case that already works correctly label-based right now)?

Good idea, will do.

There are no other index types that can end up in this case and trigger the warning?

Brainstorming I came up with 2 more cases; will update the whatsnew

msg = "Treating integers as positional in Series.__setitem__"

ii = IntervalIndex.from_breaks(range(10))[::2]
ser2 = Series(range(len(ii)), index=ii)
expected2 = ser2.copy()
expected2.iloc[-1] = 9

with tm.assert_produces_warning(FutureWarning, match=msg):
    ser2[4] = 9
tm.assert_series_equal(ser2, expected2)

mi = MultiIndex.from_product([[1.1, 2.1, 3.0, 4.1], ["A", "B"]])
ser3 = Series(range(len(mi)), index=mi)
expected3 = ser3.copy()
expected3.iloc[4] = 99

with tm.assert_produces_warning(FutureWarning, match=msg):
    ser3[4] = 99
tm.assert_series_equal(ser3, expected3)

@jreback
Copy link
Contributor

jreback commented Jul 1, 2021

i need to re-look can you rebase

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm. @jorisvandenbossche if comments

@jreback jreback merged commit 97ed8ee into pandas-dev:master Jul 4, 2021
@jbrockmendel jbrockmendel deleted the ref-should_fallback branch October 28, 2022 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: __getitem__[int] vs __setitem__[int] with Float64Index
3 participants