【发布时间】:2019-02-16 08:40:46
【问题描述】:
我正在尝试根据较短的 series 更新 series。
t
0 1
1 3
2 4
3 2
4 4
Name: rank, dtype: int32
Vtk
1 4
2 3
4 3
Name: rank, dtype: int64
我期待这样的输出:
t
0 1
1 4
2 3
3 2
4 3
Name: rank, dtype: int32
我跑了之后
t = t.update(Vtk)
print(t)
它表明 t 是一个无值。
t
None
我使用.update 方法错了吗?如何解决?
【问题讨论】:
-
如果您阅读手册并尝试
t.update()而不分配会发生什么?你有没有想过它是一个就地操作而不是返回任何东西? -
pandas.pydata.org/pandas-docs/stable/reference/api/… :
Modify ****in place**** using non-NA values from another DataFrame.同样适用于pandas.pydata.org/pandas-docs/stable/reference/api/…:Modify Series ***in place*** using non-NA values from passed Series.
标签: python python-3.x pandas jupyter-notebook