0

I just thought I added a column to a pandas dataframe with

df.NewColumn = np.log1p(df.ExistingColumn)

but when I looked it wasn't there! No error was raised either.. I executed it many times not believing what I was seeing but yeah, it wasn't there. So then did this:

df['NewColumn'] = np.log1p(df.ExistingColumn)

and now the new column was there.

Does anyone know the reason for this confusing behaviour? I thought those two ways of operating on a column were equivalent..

cardamom
  • 6,873
  • 11
  • 48
  • 102
  • Check [this](https://github.com/pandas-dev/pandas/issues/7175) – jezrael Oct 15 '17 at 13:17
  • Thanks for the link.. It's very messed up that it silently does _something_ but who knows exactly what and gives you no error message. I think from now on I will only use the brackets notation.. – cardamom Oct 15 '17 at 13:27

0 Answers0