需要删除.contains()中的内引号。例如,Made dummy df。
exceptions_dict = {'% Ownership': {0: 100.0,
1: 100.0,
2: 100.0,
3: 100.0,
4: 100.0,
5: 100.0,
6: 100.0,
7: 100.0,
8: 90.0,
9: 100.0},
'Ownership Audit Note': {0: '[ignore] 100% Ownership',
1: '[ignore] 100% Ownership',
2: '[ignore] 100% Ownership',
3: '[ignore] 100% Ownership',
4: '[ignore] 100% Ownership',
5: '[ignore] 100% Ownership',
6: '[ignore] 100% Ownership',
7: '[ignore] 100% Ownership',
8: 'foo',
9: 'foo'},
'Entity ID %': {0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.0,
5: 1.0,
6: 2.34e-05,
7: 0.0,
8: 1.0,
9: 1.0},
'Account # %': {0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.0,
5: 1.0,
6: 2.34e-05,
7: 0.0,
8: 2.0,
9: 2.0}}
exceptions_df = pd.DataFrame(exceptions_dict)
exceptions_df = exceptions_df[(~(exceptions_df['Ownership Audit Note'].str.contains('ignore|Ignore'))) &
(~(exceptions_df['% Ownership'] == 100.0)) &
(~(exceptions_df['Account # %'] == 'Entity ID %'))]
print(exceptions_df)
% Ownership Ownership Audit Note Entity ID % Account # %
8 90.0 foo 1.0 2.0