0

I was wondering what is the difference between, and what are the pros and cons for, setting a constant value in a new column in a dataframe using the two different approaches below:

The first being directly assigning a value to a column

df["column"] = "value"

The second using .loc

df.loc[:, "column"] = "value"

Thanks!

scotscotmcc
  • 2,719
  • 1
  • 6
  • 29
Mit
  • 679
  • 6
  • 17
  • some discussion on the question over here: https://stackoverflow.com/questions/38886080/python-pandas-series-why-use-loc – scotscotmcc Nov 21 '22 at 19:03

0 Answers0