0

Assuming I know which column to look in and that the cell contains a unique character within a string, what's the best way to scan through the cells and return the value of the one containing that unique character and other characters I don't know?

For example, if I want to find the value of a cell that contains 'W' in the string stored there in df['A'], how can I return that cell's complete string?

  • Can you be more specific? Can you create [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) ? – jezrael Feb 07 '20 at 06:47

1 Answers1

0

You can use a list comprehension. The following code will return the list of all cells in column 'A' where you have the character 'W'.

[x for x in df['A'].values if 'W' in x]
Fehnryr
  • 255
  • 2
  • 9