0

I know this has been asked before but my case is slightly different . I am using the below .

    train_mask = df_train['category_count'] == 3

    df_train.loc[train_mask]['cat1'] = df_train.loc[train_mask]['categories'][0[0]
    df_train.loc[train_mask]['cat2'] = df_train.loc[train_mask]['categories'][0][1]
    df_train.loc[train_mask]['cat3'] = df_train.loc[train_mask]['categories'][0][2]


where for eg : df_train['categories'] is a list  : ["Shirt","Trousers","Shoes"]

I am using the .loc method inspite of which i keep getting the below error .Can someone please explain why .

C:\Users\sraghunath\AppData\Local\Continuum\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

user1411837
  • 1,494
  • 6
  • 27
  • 41

0 Answers0