I have the following column (within a broader Dataframe):
>>> d['date']
date
2017-04-06
2017-04-05
2017-03-28
2017-04-06
I want to turn these dates into a string like: March 2016, Week 12. I am doing the following (which works fine):
d['date'] = d['date'].apply(lambda x: x.strftime('%B %Y, Week %W'))
I have the result I want but, unfortunately I get the following warning:
file.py:53: 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 have tried to check other issues in SO and read pandas documentation but I am not too sure how to handle it as my various attempts have failed yet (e.g. using .loc()
). What is proper way to do what I want to do?
Thanks!