I have a pandas dataframe
df
store day items
a 1 4
a 1 3
a 2 1
a 3 5
a 4 2
a 5 9
b 1 1
b 2 3
I have another pandas dataframe temp
that is the kronecker product of all unique store-day combinations, that is, it looks like:
store day
0 a 1
1 a 2
2 a 3
3 a 4
4 a 5
5 b 1
6 b 2
7 b 3
8 b 4
9 b 5
I want to make a new DF that is the missing observations in df, that is, the store-day combinations not present in df but present in temp.
desired output
store day
b 3
b 4
b 5
This is one way
gcols = ['store', 'date']
tmp[tmp.set_index(gcols).index.isin(df.set_index(gcols).index) == False]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With