0

Hey so I was working on this problem and I put this code in and I got a warning back and I was confused because I do not understand what this warning is trying to say. If anyone can help me understand I would greatly appreciate it. Thank you!

df['year_added'] = df.loc[:,'date_added'].dt.year
df['month_added'] = df.loc[:,'date_added'].dt.month

df['season_count'] = df.apply(lambda x : x['duration'].split(" ")[0] if "Season" in x['duration'] else "", axis = 1)
df['duration'] = df.apply(lambda x : x['duration'].split(" ")[0] if "Season" not in x['duration'] else "", axis = 1)
df.head()

C:\Users\Shahzaib\Anaconda3\lib\site-packages\ipykernel_launcher.py:1: 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
  • Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – bb1 Aug 14 '21 at 19:29

0 Answers0