I have a pandas dataframe:
col1 | col2 | col3 | col4 |
0. A | B | C | G|
1. I | J | S | D|
2. O | L | C | G|
3. A | B | H | D|
4. H | B | C | P|
# reproducible
import pandas as pd
from string import ascii_uppercase as uc # just for sample data
import random # just for sample data
random.seed(365)
df = pd.DataFrame({'col1': [random.choice(uc) for _ in range(20)],
'col2': [random.choice(uc) for _ in range(20)],
'col3': [random.choice(uc) for _ in range(20)],
'col4': [random.choice(uc) for _ in range(20)]})
I'm looking for a function like this:
func('H')
which will return all the names of indexes and columns where "H" is. Any ideas?