-2

dataframe called condition produces the below output:

      SUBJID                                    LBSPCCND    LBSPCCND_OTHER
0   0292-104                           Adequate specimen                  
1   1749-101                                       Other    Limited Sample
2   1733-104  Paraffin block; paraffin-embedded specimen                  
3   0587-102                                       Other  Pathology Report
4   0130-101                           Adequate specimen                  
5   0587-101                           Adequate specimen                  
6   0609-102                                       Other      Unacceptable

When I run the below code, I'm getting a settingwithcopywarning:

condition["LBSPCCND"] = condition["LBSPCCND"].apply(convert_condition) 
condition

      SUBJID           LBSPCCND    LBSPCCND_OTHER
0   0292-104           ADEQUATE                  
1   1749-101              Other    Limited Sample
2   1733-104  PARAFFIN-EMBEDDED                  
3   0587-102              Other  Pathology Report
4   0130-101           ADEQUATE                  
5   0587-101           ADEQUATE                  
6   0609-102              Other      Unacceptable

This generates this error:

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
  • Refrain from showing your dataframe as an image. Your question needs a minimal reproducible example consisting of sample input, expected output, actual output, and only the relevant code necessary to reproduce the problem. See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) for best practices related to Pandas questions. – itprorh66 Feb 13 '23 at 15:08

1 Answers1

0

Copy() of my dataframe got rid of the error:

columns = ["SUBJID", "LBSPCCND", "LBSPCCND_OTHER"]
condition = igan[columns].copy()
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40