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.