刚刚安装了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)
有人可以指导我使用新语法吗?
谢谢,
吕克
答案 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