使用numpy替换数据框值时出现错误

时间:2019-11-20 12:34:20

标签: python python-3.x pandas numpy

我是python新手,这里有一个数据框

id    values
1      100
2      200
3      3600
4      3654

现在,在这里我尝试使用以下方式替换值

file_name = file_name.loc[file_name['values'] == 3654,file_name['values'] ,3600]

这里的值就像,

if 3654 is then replace it with 3600 otherwise keep it as it is.

所以,我得到了这个错误,

only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

有人可以帮我吗?

0 个答案:

没有答案