0

I have a situation where this code is resulting in SettingwithCopyWarning warning...

def load(source):
   return pd.read_json(source)

def doStuff(df):
   ...

df = load('file.json')
doStuff(df) # -> SettingwithCopyWarning 

But this is ok...

def doStuff(df):
   pd.read_json(source)
   ...

doStuff('file.json') # ok!

Why would loading the df in a separate function and passing it to another function result in this warning? I expect it to pass the same df by reference.

Ian
  • 141
  • 1
  • 1
  • 7
  • Does this answer your question? [How to deal with SettingWithCopyWarning in Pandas](https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas) – PV8 Aug 24 '23 at 11:37

0 Answers0