.iloc[:] and .loc[:] return the original object (original) (raw)
Each of these asserts should fail:
on pandas 0.18.1
import pandas as pd
df = pd.DataFrame({'x': range(3)}) assert df.iloc[:] is df assert df.loc[:] is df
series = df.x assert series.iloc[:] is series assert series.loc[:] is series
Instead, for the sake of predictability, these should always return a new DataFrame/Series, even if they reuse the same data. See here for an example of how this resulted in a user facing bug within pandas.
Thanks @mborysow for pointing this out.