2

刚刚安装了 pandas 0.10.0,以下行创建现有列的插值版本失败:

prep_bcgps['lati'] = prep_bcgps['lat'].apply(pds.Series.interpolate)

TypeError: unbound method interpolate() must be called with Series instance as first argument (got float64 instance instead)

有人可以指导我使用新语法吗?

谢谢,

卢克

4

1 回答 1

2

尝试:

prep_bcgps['lati'] = prep_bcgps['lat'].interpolate()

例如:

df = pd.DataFrame({'X' : [1, None, 3, None, 5]})
print(df)
#     X
# 0   1
# 1 NaN
# 2   3
# 3 NaN
# 4   5

df['X'] = df['X'].interpolate()
print(df)
#    X
# 0  1
# 1  2
# 2  3
# 3  4
# 4  5
于 2012-12-19T22:19:10.387 回答