I have the following data frame
df = pd.DataFrame([[1990,7,1000],[1990,8,2500],[1990,9,2500],[1990,9,1500],[1991,1,250],[1991,2,350],[1991,3,350],[1991,7,450]], columns = ['year','month','data1'])
year month data1
1990 7 1000
1990 8 2500
1990 9 2500
1990 9 1500
1991 1 250
1991 2 350
1991 3 350
1991 7 450
I would like to filter the data such that it won't contain data with month/year 07/1990, 08/1990 and 01/1991. I can do for each combination month/year as follow:
df = df.loc[(df.year != 1990) | (df.month != 7)]
But it is not efficient if there are many combinations month/year. Is there any more efficient way of doing this?
Many thanks.