-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: InvalidIndexError using at for multiple assignment #51866
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
Comments
when I try this I get InvalidIndexError: You can only assign a scalar value not a <class 'float'> so it looks like a clear error message has already been added |
closing as a duplicate of #48729 then |
Hmm, I'm not sure I agree with you. (Also not sure why I'm not actually seeing that error message.) "You can only assign a scalar value not a <class 'float'>" does not tell me that the problem is that I gather that the new way to do this kind of multiple-element assignment is using |
you might be on an old version of pandas, please try upgrading but you're right, the error message probably can be improved for when you're trying to set a scalar but with a mask - reopening then |
@MarcoGorelli I'd suggest something like this: "Tried to set a scalar value with a mask, please use a scalar index or use df.loc instead". What do you think? |
i haven't looked at this closely, but it it's possible to add that error message in such a way that it wouldn't be incorrect in some cases, then that looks good interested in opening a pull request? |
Research
I have searched the [pandas] tag on StackOverflow for similar questions.
I have asked my usage related question on StackOverflow.
Link to question on StackOverflow
https://stackoverflow.com/questions/75688441/pandas-invalidindexerror-during-multiple-assignment-using-at
Question about pandas
This might not be a bug, so I'm not opening the issue as a bug.
I used to rely on
at
for multiple assignment in the following way:which produces (my desired output) in
pandas
versions from 1.2.3 to 1.3.5 (I did not test before 1.2.3):As of version 1.4.0 (and above), the same code produces the following error
Is this a bug? Should this work?
If this is the desired behavior, a more descriptive error message would help others debug much faster.
The text was updated successfully, but these errors were encountered: