【发布时间】:2018-06-22 19:30:49
【问题描述】:
我正在处理一个数据框,其中我的一个列需要根据一组标准和行中其他列提供的数据进行更新和更改。
有问题的行是标价货币。
如果它前面的列(价格手册名称)包含 Amer,我希望将标价货币更新为美元列表。如果价格手册没有显示 Amer,我希望将货币更新为 Intl USD。否则,如果价格手册名称中包含 GBP,我只想将其更改为 UK list,并将 EUR 更改为 Euro List。
我尝试编写一个小的 for 循环来遍历每个标价货币并根据价格手册名称的内容对其进行更新,但它实际上并没有对列中的单元格做任何事情。
任何帮助或指导将不胜感激!
for column in datagrouped['List Price Currency']:
if 'List Price Currency' == "USD":
if 'Price Book Name'.str.contains("Amer"):
'List Price Currency' == "US List"
else: 'List Price Currency' == "Intl USD"
if "List Price Currency" == "GBP":
"List Price Currency" == "UK List"
if "List Price Currency" == "EUR":
"List Pricy Currency" == "Euro List"
【问题讨论】: