我想设置 pandas 数据框列的多个值 where 条件,但收到错误消息:
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
最佳答案
试试这个:
df.ix[df['store_id'] == 'UK00023', ['sale','startdate','enddate']] = [100, str(datetime.now()), str(datetime.now())]
关于python - 如何设置Pandas数据框where条件的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41593389/