Skip to content

Commit b366925

Browse files
author
tp
committed
NDFrame.astype doc string, adding part with copy=False
1 parent d9b9411 commit b366925

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: pandas/core/generic.py

+12
Original file line numberDiff line numberDiff line change
@@ -3665,6 +3665,18 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs):
36653665
1 2
36663666
dtype: category
36673667
Categories (2, int64): [2 < 1]
3668+
3669+
Note that using ``copy=False`` and changing data on a new
3670+
pandas object may propagate changes upwards:
3671+
3672+
>>> cat1 = pd.Series([1,2], dtype='category')
3673+
>>> cat2 = cat1.astype('category', copy=False)
3674+
>>> cat2[0] = 2
3675+
>>> cat1 # note that cat1[0] is changed too
3676+
0 2
3677+
1 2
3678+
dtype: category
3679+
Categories (2, int64): [1, 2]
36683680
"""
36693681
if is_dict_like(dtype):
36703682
if self.ndim == 1: # i.e. Series

0 commit comments

Comments
 (0)