我想设置一个条件的pandas dataframe列的多个值,但是我收到了一条错误消息:
df[df['store_id'] == 'UK00023', ['sale','startdate','enddate']] = [100, str(datetime.now()), str(datetime.now())]
But I got this error:
raise ValueError('Length of values does not match length of '
ValueError: Length of values does not match length of index
答案 0 :(得分:3)
试试这个:
df.ix[df['store_id'] == 'UK00023', ['sale','startdate','enddate']] = [100, str(datetime.now()), str(datetime.now())]