I keep running into the following warning in pandas but I am failing to see why.
let's say I have a dataframe and I create a new column this way:
x = pd.DataFrame({'A':[1,2,3]})
x['AA'] = x['A']
I do not get any warning.
But I basically do the same for a Df I get from a SQL db and I get a warning.
m = rs.selectQueryIntoPandas(sql)
# filter out all rigs with NULL ID - out: m1
null_flag = rigs['id'].isnull()
n_nulls = sum(null_flag)
m1 = m.loc[~null_flag]
id_cleaned = m1['id'].apply(lambda x: cleanId(x))
m1['id_orig'] = m1['id']
/home/ubuntu/.pycharm_helpers/pydev/pydevconsole.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
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
'''
I have no idea why.