Pandas插值在版本0.10中发生了变化?

时间:2012-12-19 22:11:18

标签: python pandas interpolation

刚刚安装了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)

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

谢谢,

吕克

1 个答案:

答案 0 :(得分: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