0

What is the technical difference between selecting columns in Pandas DataFrame by providing column as atribute or as a string in the brackets (sorry, don't know exact expresion of what it is called)?

Example:

df  = pd.read_csv("file.csv", index_col=0)
df1 = df[df.village == 1]
df2 = df[df['village'] == 1]

df1 is df2 returns False.

Also, would appreciate if someone could explain any further possible manipulation differences between newly created df1 and df1. I mean can I return different results compared to each method?

I also wasn't able to compare their == value. Don't know how.

Sajan
  • 1,247
  • 1
  • 5
  • 13
cabavyras
  • 59
  • 7
  • 1
    look here for an answer to your question: https://stackoverflow.com/questions/132988/is-there-a-difference-between-and-is == is not the same as is – kjul May 10 '20 at 21:16
  • To find out if two dataframes have the same content, you can use [`DataFrame.equals`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.equals.html). – Gerd May 11 '20 at 13:06

0 Answers0