0

Let's say we have a pandas dataframe called train and it has a column called Age. What is the difference between method 1 and method 2.

avg1 = train.Age.mean() 
avg2 = train['Age'].mean()
DSG
  • 183
  • 1
  • 2
  • 8
  • No difference, so long as `Age` is not a property of the dataframe (which it is not in this case). Also, duplicate of https://stackoverflow.com/questions/41130255/in-a-pandas-dataframe-whats-the-difference-between-using-squared-brackets-or-d – Alexander Mar 23 '18 at 02:53
  • @Alexander Thanks, that duplicate is much more appropriate. – cs95 Mar 23 '18 at 02:56

0 Answers0