this piece of code throws the well-known and much-discussed "A value is trying to be set on a copy of a slice from a DataFrame" error. I have read several of the threads about the topic on this site but couldn't find any useful information.
df = load_data() # comes straight from pandas.read_sql()
f_200 = df.Programm.str.contains(r'(?:-CMF|8$)')
df['Groesse'] = '150'
df['Groesse'][f_200] = '200' # this throws the warning
For the purpose of this question I tried to reproduce the error with this minimal piece of code:
a = pandas.DataFrame([1,2], columns=["a"])
i = pandas.Series([True, False])
a['a'][i] = 10
However, this works fine. I don't understand this. Is there anything the matter with a data frame obtained from a call to pandas.read_sql()?