-
-
Notifications
You must be signed in to change notification settings - Fork 19k
Closed
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
df = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
df.at[2] = [5, 6]
On 1.4.x, this gives
a b
0 1.0 3.0
1 2.0 4.0
2 5.0 6.0
whereas on 1.5.0rc0 it gives pandas.errors.InvalidIndexError: slice(None, None, None)
. I didn't any mention of this in the whatsnew, and a git bisect points at #47074; cc @jorisvandenbossche.
The docs of DataFrame.at
explicitly say a KeyError is raised when the label is not in the frame. It seems to me this operation should not be supported, and can be considered a bugfix, but would be better to raise KeyError: label 2 not found
.
Metadata
Metadata
Assignees
Labels
BugIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Type
Projects
Relationships
Development
Select code repository
Activity
phofl commentedon Aug 29, 2022
Hm I think InvalidIndexError is ok too, since at is for one value only and this tries to update 2
although the message is not optimal
rhshadrach commentedon Aug 29, 2022
I see; the
slice(None, None, None)
is referring to the columns - thanks. That makes sense, but this doesn't raise on main:and instead adds a row. I believe this should raise a KeyError, and think it would be preferable for the OP example to also raise a KeyError. If the key were to exist, InvalidIndexError in the OP makes sense to me (perhaps with a better message if possible).
I plan to add a note in the whatsnew in the indexing bugfixes section to close this issue and open a new issue on changing the behavior of
.at
, but I think the behavior change should wait until after the 1.5. release.phofl commentedon Aug 29, 2022
This is probably related to #48224 somehow. Maybe you could combine them when opening a new issue
az.compare()
fails with the documentation example arviz-devs/arviz#2149