I am comparing the output of accessing a pandas DataFrame via iloc[]
vs dot notation (e.g. df.column1
). The results are unexpected…
df = pd.DataFrame([[1,2]], columns=['one', 'two'])
df.iloc[:,0] is df.one
Unexpectedly, this code returns:
False
Even after assignment, df.one = df.iloc[:,0]
, the code df.iloc[:0] is df.one
returns False
I presume one of these accessing methods is producing a copy but I have failed to find evidence in the docs or on form pages. I have done similar tests with bracket notation and the same output was produced.
rootdrew27 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.