[英]Replace values in column based on condition, then return dataframe
I'd like to replace some values in the first row of a dataframe by a dummy. 我想用假人替换数据框第一行中的某些值。
df[[0]].replace(["x"], ["dummy"])
The problem here is that the values in the first column are replaced, but not as part of the dataframe. 这里的问题是替换了第一列中的值,但没有将其作为数据框的一部分。
print(df)
yields the dataframe with the original data in column 1. I've tried 产生具有第1列中原始数据的数据框。我尝试过
df[(df[[0]].replace(["x"], ["dummy"]))]
which doesn't work either.. 这也不起作用..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.