'Mapping Error: A value is trying to be set on a copy of a slice from a DataFrame

I get the error: “A value is trying to be set on a copy of a slice from a DataFrame” when I try to map. I’m not sure how to fix this. I’ve tried .loc but that doesn’t work either.

df1[‘Total’] = df1[‘Year’].map(df2.set_index(‘Year’)[‘Total’])


Solution 1:[1]

In the event no one is able to come up with a more elegant solution, here's one that at least would work for you. Not too bad if you only need to compare the 5 columns, could be a bit more painstaking if you have more.

=AND(OR($C2="day",$C2="both"),OR($D2="day",$D2="both"),OR($E2="day",$E2="both"),OR($F2="day",$F2="both"),OR($G2="day",$G2="both"))

The And() function, as you are likely already aware, requires that each and every value within it returns a True value to have it output a value of True.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 K.Dᴀᴠɪs