Consider the following example.
import pandas as pd
df = pd.DataFrame({
"x": [1, 2, 3],
"y": [4, 5, 6]
})
x = df["x"]
df.drop(index=[0], inplace=True)
Now we have x._is_view
is True
, so I would expect x
to be a "view" into df
. In other words, I would expect x
to be identical to df["x"]
.
However, x
still contains the values [1, 2, 3]
, while df["x"]
only contains the values [2, 3]
.
In what sense is x
a view?
P.S. In my head, I have been imagining that df.drop(..., inplace=True)
is literally dropping rows of df
from memory. Perhaps this is not the case...