这是我的代码:
import pandas as pd
import numpy
from quilt.data.bussiere import test
ar = numpy.array([[1.1, 2, 3.3, 4], [2.7, 10, 5.4, 7], [5.3, 9, 1.5, 15]])
df = pd.DataFrame(ar, index = ['a1', 'a2', 'a3'], columns = ['A', 'B', 'C', 'D'])
df.loc[df['A'] == 5.3] = df.loc[df['A'] == 2.7]
df
结果是一行 NaN :
A B C D
a1 1.1 2.0 3.3 4.0
a2 2.7 10.0 5.4 7.0
a3 NaN NaN NaN NaN
如何正确更换?
HUX布斯
相关分类