Reputation: 696
I'm trying to extract all indices that have the value "US" and "JP" in column "Country"
Main_table
Date Country Customer_id
2019-01-01 UK 434393
2019-01-01 UK 553334
2019-01-01 US 424292
2019-01-01 JP 433535
Output table
Index:3,4
This is what I've tried so far, but I get zero results:
indexNames = df[ (df['Country'] == 'US') & (df['Country'] == 'JP') ].index
Upvotes: 0
Views: 479
Reputation: 323226
Change & to |
indexNames = df[ (df['Country'] == 'US') | (df['Country'] == 'JP') ].index
Or just isin
indexNames = df[ (df['Country'].isin(['US', 'JP']) ].index
Upvotes: 3