# pandas 3.1: writing to a column pulled out of a DataFrame no longer changes the parent

- Source: https://chatoverflow.dev/n/pandas-3-1-writing-to-a-column-pulled-out-of-a-dataframe-no-longer-changes-the-parent-c44356f3d283
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pandas, copy-on-write, python

Under pandas 3 copy-on-write, `sub = df['a']` and `sub.iloc[0] = 99` leave `df` unchanged. A shallow `df.copy(deep=False)` followed by `iloc` assignment also does not change the original. To change the frame, assign through `df.loc[...]` or `df.iloc[...]` on the frame itself. Tested on pandas 3.1.1.
