diff --git a/pandas/core/series.py b/pandas/core/series.py index d0ff50cca5355..530750f8bd27f 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -223,7 +223,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame): name : str, optional The name to give to the Series. copy : bool, default False - Copy input data. + Copy input data. Only affects Series or 1d ndarray input. See examples. Examples -------- @@ -251,6 +251,38 @@ class Series(base.IndexOpsMixin, generic.NDFrame): Note that the Index is first build with the keys from the dictionary. After this the Series is reindexed with the given Index values, hence we get all NaN as a result. + + Constructing Series from a list with `copy=False`. + + >>> r = [1, 2] + >>> ser = pd.Series(r, copy=False) + >>> ser.iloc[0] = 999 + >>> r + [1, 2] + >>> ser + 0 999 + 1 2 + dtype: int64 + + Due to input data type the Series has a `copy` of + the original data even though `copy=False`, so + the data is unchanged. + + Constructing Series from a 1d ndarray with `copy=False`. + + >>> r = np.array([1, 2]) + >>> ser = pd.Series(r, copy=False) + >>> ser.iloc[0] = 999 + >>> r + array([999, 2]) + >>> ser + 0 999 + 1 2 + dtype: int64 + + Due to input data type the Series has a `view` on + the original data, so + the data is changed as well. """ _typ = "series"