[英]How to add specific value in column in in every row in dataframe
here i am trying add (EA) in every record for column 1 is it possible to save value in column 1 like 1.0 Each(EA) followed by 0.0 / 0.001 (EA)... 在这里我正在尝试在第1列的每条记录中添加(EA),是否有可能在第1列中保存值,例如1.0 Each(EA)后跟0.0 / 0.001(EA)...
df_1
Out[46]:
0 1
0 Unit of Measure Each (EA)
1 Conversion 1.0 Each
2 Net/Gross Weight (lbs) 0.0 / 0.001
3 Volume (cubic ft) 0.0
4 Shipping Dimensions (inch) L x W x H 0.589 x 0.589 x 0.589
5 GTIN NaN
Use: 采用:
df['1'].apply(lambda x: str(x) + '(EA)' if '(EA)' not in str(x) else x)
if the name of column not is a str
then use: 如果列的名称不是
str
则使用:
df[1].apply(lambda x: str(x) + '(EA)' if '(EA)' not in str(x) else x)
Try this 尝试这个
df['1']=df['1']+ '(EA)'
It will add (EA) to every row except for the row that has NaN
它将为每行添加(EA),但具有
NaN
行除外
df_1['1'] = df_1['1'] + " (EA)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.