0

I'm recently new to python. I've been trying to transform the date contents of a column into a new column containing the month and year which can the be grouped by a seaborn box plot function. Assume lcd_raw_clean is a pandas dataframe containing feature 'issue_d' which is datetime dtype.

The code I'm using

lcd_raw_clean['issue_YYMM'] = lcd_raw_clean['issue_d'].apply(lambda x: x.strftime('%Y%m')) 

Generates the warning:

/Applications/anaconda/lib/python2.7/site-packages/IPython/kernel/__main__.py:7: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

I cannot understand why this generates this warning and how to get around it.

Blckknght
  • 93,977
  • 11
  • 112
  • 159
GPB
  • 2,233
  • 8
  • 23
  • 35

0 Answers0