得到错误消息太多索引器使用pandas。下列代码
import pandas as pd
userlist = ['Smith', 'Clark']
df = pd.read_csv("sample.csv")
for i, df in df.iterrows():
if (df['Last Name']) in userlist:
df.at[1,'Runner']='Yes'
else:
pass
csv:
Last Name,Frist Name,email,Runner,Vistor
Doe,John,jdoe@123.com,Yes,Yes
Smith,Shawn,ssmith@test.org,No,Yes
Brown,Beth,bbrown@school.org,Yes,No
Clark,Tom,tclark@work.com,No,Yes
我有一个大型数据集,其中包含需要更新单元格的名称列表,并将循环遍历列表以更改单元格。请帮助。由于
import pandas as pd
userlist = ['Smith', 'Clark']
df = pd.read_csv("sample.csv")
df['Runner'][df['Last Name'].isin(userlist)]='Yes'