@@ -8826,26 +8826,27 @@ def update(
8826
8826
1 b e
8827
8827
2 c f
8828
8828
8829
- For Series, its name attribute must be set.
8830
-
8831
8829
>>> df = pd.DataFrame({'A': ['a', 'b', 'c'],
8832
8830
... 'B': ['x', 'y', 'z']})
8833
- >>> new_column = pd.Series(['d', 'e'], name='B' , index=[0, 2])
8834
- >>> df.update(new_column )
8831
+ >>> new_df = pd.DataFrame({'B': ['d', 'f']} , index=[0, 2])
8832
+ >>> df.update(new_df )
8835
8833
>>> df
8836
8834
A B
8837
8835
0 a d
8838
8836
1 b y
8839
- 2 c e
8837
+ 2 c f
8838
+
8839
+ For Series, its name attribute must be set.
8840
+
8840
8841
>>> df = pd.DataFrame({'A': ['a', 'b', 'c'],
8841
8842
... 'B': ['x', 'y', 'z']})
8842
- >>> new_df = pd.DataFrame({'B': ['d', 'e']}, index=[1, 2] )
8843
- >>> df.update(new_df )
8843
+ >>> new_column = pd.Series( ['d', 'e', 'f'], name='B' )
8844
+ >>> df.update(new_column )
8844
8845
>>> df
8845
8846
A B
8846
- 0 a x
8847
- 1 b d
8848
- 2 c e
8847
+ 0 a d
8848
+ 1 b e
8849
+ 2 c f
8849
8850
8850
8851
If `other` contains NaNs the corresponding values are not updated
8851
8852
in the original dataframe.
0 commit comments