2

I have df:

{'col1': {0: 'vJAaIAM',
  1: 'K0jQAF',
  2: '00qvP1IIU',
  3: 'tFCJ2',
  4: '0d2fIAB'},
 'col2': {0: 6294.0,
  1: 859485.0,
  2: 7362.0,
  3: 6273921.0,
  4: 114506.0}}

and I am looking to query this dataframe for all rows that have capital 'A' and here is what I have:

df[df['col1']==r'+%[A]%+']

I'm not needing to replace these values, I simply want to list and see them.

user3486773
  • 1,174
  • 3
  • 25
  • 50

1 Answers1

2

You can use .str.contains('A') [pandas-doc] here:

>>> df[df['col1'].str.contains('A')]
      col1      col2
0  vJAaIAM    6294.0
1   K0jQAF  859485.0
4  0d2fIAB  114506.0
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555