8000 `Series.loc`, `Series.iloc`, `DataFrame.loc` and `DataFrame.iloc` not accepting singular slice arguments for `__setitem__()` (and possibly `__getitem()`) · Issue #572 · pandas-dev/pandas-stubs · GitHub
[go: up one dir, main page]

Skip to content

Series.loc, Series.iloc, DataFrame.loc and DataFrame.iloc not accepting singular slice arguments for __setitem__() (and possibly __getitem()) #572

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
randolf-scholz opened this issue Mar 14, 2023 · 1 comment · Fixed by #1087
Labels
Indexing Related to indexing on series/frames, not to indexes themselves

Comments

@randolf-scholz
Copy link
Contributor

Describe the bug

To perform complicated in-place operations, one can do df.loc[:] = ..., to simply assign the updated array. This is currently unsupported by pandas-stubs.

To Reproduce

from pandas import DataFrame, Series

foo = Series([1, 2, 3])
foo.loc[:] = 1 + foo  # [call-overload]

bar = DataFrame([1, 2, 3])
bar.loc[:] = 1 + bar  # [call-overload]

Please complete the following information:

  • pandas 1.5.3
  • pandas-stubs 1.5.3.230304
@Dr-Irv
Copy link
Collaborator
Dr-Irv commented Mar 14, 2023

Have to add singluar slice arguments to __getitem__() and __setitem__() in the right places for dataframe.pyi in _LocIndexerFrame and _ILocIndexerFrame and series.pyi in _LocIndexerSeries and ILocIndexerSeries.

Needs a fair bit of tests to make sure this is done correctly.

@Dr-Irv Dr-Irv added the Indexing Related to indexing on series/frames, not to indexes themselves label Mar 14, 2023
@Dr-Irv Dr-Irv changed the title [call-overload] No overload variant of "__setitem__" of "_LocIndexerSeries" matches argument types "slice", "Any" [call-overload] Series.loc, Series.iloc, DataFrame.loc and DataFrame.iloc not accepting singular slice arguments for __setitem__() (and possibly __getitem()) Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
0