简体   繁体   English

如何在条件下设置熊猫数据框的多个值

[英]How to set multiple values of Pandas dataframe where condition

I want to set multiple values of pandas dataframe columns where a condition, but I got an error message: 我想在其中设置条件的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

尝试这个:

df.ix[df['store_id'] == 'UK00023', ['sale','startdate','enddate']] = [100, str(datetime.now()), str(datetime.now())]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM