You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [59]: df=pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
In [60]: df2=df.reset_index()
In [61]: df2.iloc[0, 0] =100
is intended to illustrate that a copy (on write) will be created, because df and df2 reference the same data. In reality, no copy will be created because df2.iloc[0, 0] refers to the newly created integer column storing the reset index, which exists for df2, but not for df.
Suggested fix for documentation
Replace the last line of the snippet,
In [61]: df2.iloc[0, 0] =100
with:
In [61]: df2.iloc[0, 1] =100
The text was updated successfully, but these errors were encountered:
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/dev/user_guide/copy_on_write.html#patterns-to-avoid
Documentation problem
This code snippet
is intended to illustrate that a copy (on write) will be created, because
df
anddf2
reference the same data. In reality, no copy will be created becausedf2.iloc[0, 0]
refers to the newly created integer column storing the reset index, which exists fordf2
, but not fordf
.Suggested fix for documentation
Replace the last line of the snippet,
with:
The text was updated successfully, but these errors were encountered: