9

Fix “unsupported-assignment-operation” error for Pandas

 1 year ago
source link: https://donghao.org/2022/07/05/fix-unsupported-assignment-operation-error-for-pandas/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fix “unsupported-assignment-operation” error for Pandas

When using pylint to check my code, it reported an error:

E1137: 'df' does not support item assignment (unsupported-assignment-operation)
Shell
E1137: 'df' does not support item assignment (unsupported-assignment-operation)

for the origin code:

df["column1"] = "hello"
Python
df["column1"] = "hello"

It looks like we have no choice but to use operation .loc in pandas to avoid this error.

# Set all rows in "column1" to "hello"
df.loc[:, "column1"] = "hello"
Python
# Set all rows in "column1" to "hello"
df.loc[:, "column1"] = "hello"

Related Posts

July 5, 2022 - 0:44 RobinDong develop
pandas
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK