-1

Are the two lines of code equivalent to each other? To me the results seem the same, but I seen libraries use the second method, perhaps there is a reason why?

df['some_column']

df.loc[:, 'some_column']
katiex7
  • 863
  • 12
  • 23

1 Answers1

1

they're equivalent here, but the .loc and .iloc accessors lets you express indexing operations that would be otherwise ambiguous and could lead to it doing the "wrong" thing or would otherwise be confusing readers of your code

Sam Mason
  • 15,216
  • 1
  • 41
  • 60