2024-06-28 20:03:02 发布
网友
我有一个CSV文件,其中一列标题为“类型”。在本专栏下,我试图将价值观“福特”和“GMC”替换为“汽车”。我相信就我所拥有的而言,格式肯定有问题。请告知
df_jobs["Type"].replace(to_replace = "Ford", "GMC", value = "Automotive", inplace=True)
我得到的错误是
"SyntaxError: positional argument follows keyword argument"
错误是不言自明的"GMC"是一个位置参数,后跟to_replace = "Ford",这是一个关键字参数。 您需要的是列出"Ford"和"GMC",然后将其传递给to_replace键:
"GMC"
to_replace = "Ford"
"Ford"
to_replace
df_jobs["Type"].replace(to_replace = ["Ford", "GMC"], value = "Automotive", inplace=True)
错误是不言自明的
"GMC"
是一个位置参数,后跟to_replace = "Ford"
,这是一个关键字参数。您需要的是列出
"Ford"
和"GMC"
,然后将其传递给to_replace
键:相关问题 更多 >
编程相关推荐