The Original DataFrame(df1) looks like:
NoUsager Sens NoAdresse Fait Weekday NoDemande Periods
0 000001 + 000079 1 Dim 42191000972 Soir
1 001875 + 005018 1 Dim 42191001052 Matin
2 001651 + 005018 1 Dim 42191001051 Matin
3 001486 + 000405 1 Dim 42191001250 Matin
4 002021 + 005712 1 Dim 42191000013 Matin
5 001975 + 005712 1 Dim 42191000012 Matin
6 001304 + 001408 1 Dim 42191000371 Matin
7 001355 + 005021 1 Dim 42191000622 Matin
8 002274 + 006570 1 Dim 42191001053 Matin
9 000040 + 004681 1 Dim 42191002507 Soir
I used crosstab to generate a new one(df2) with index = NoDemande, NoUsager, Periods and columns = ['Sens']:
Sens + -
NoDemande NoUsager Periods
42191000622 001355 Matin 1 2
42191000959 001877 Matin 1 2
42191001325 000627 Soir 1 2
42191001412 000363 Matin 1 2
42191001424 000443 Soir 1 2
42191001426 001308 Soir 1 2
42191002507 000040 Soir 2 0
42193000171 000257 Soir 1 2
42193000172 002398 Soir 1 2
I want to drop all the rows from df1 where values in columns NoUsager and NoDemande are the same as the one in index NoUsager and NoDemande in df2. So the result will return a new DataFramedf3 with the same df1 format but without line7 and line9.
I tried:
df3 = df1.loc[~df1['NoDemande','NoUsager'].isin([df2.NoDemande,df2.NoUsager])]
But it returned: KeyError: ('NoDemande', 'NoUsager')
How can I solve this problem?
Any help will be appreciated!
