1

I am trying to do the following.

df_county_outcomes['county'] = df_county_outcomes['county'].apply(lambda x : '0' + str(x) if len(str(x)) == 1 else str(x))

I get the correct result but the SettingWithCopyWarning will always be there. Can someone help? Thanks a lot in advance!

  • It would be great if you can show the dataframe, as creating a basic dataframe with a ```county``` column with random data in it does not give me any ```SettingWithCopyWarning```, check your version of pandas, this could possibly be a issue. – thmasXX Nov 09 '22 at 22:34

1 Answers1

0

It could be due to a few reasons. This article helped me immensely.

TLDR is you can use pd.set_option('mode.chained_assignment', None) to suppress that warning if you are certain what you're doing is okay. In your case it looks like you can suppress the warning.

cmauck10
  • 163
  • 3