I am a Python starter using Python 3.7.0 so apologies for the blunders with my code below. I have imported an excel spreadsheet into a dataframe which shows in Jupyter as below.
    Title  Name1  Name2  Name3  Name4
0    A       P             O      P
1    B              P             O
2    C              P      P      P
3    D       P                    P
I am trying to find value 'P' for each row and print the Title label followed by all the column headers with that found value.
The desired output is better illustrated for what I am trying to achieve below:
Output:
Title A: Name1, Name4
Title B: Name2
Title C: Name2, Name3, Name4
Title D: Name1, Name4
This is my code so far:
#Sample data to recreate pd in this forum
data = {'Title':  ['A', 'B','C', 'D'],
        'Name1': ['P', '', '','P'],
        'Name2': ['', 'P','P',''],
        'Name3': ['O', '','P',''],
        'Name4': ['P', 'O','P','P'],
        }  
# Create the pandas DataFrame 
df_so = pd.DataFrame(data, columns = ['Title', 'Name1', 'Name2', 'Name3', 'Name4']) 
Neither of the codeblocks below return an output
First attempt:
for (index_label,row_series) in df_so.iterrows():
    if row_series == 'P':
        print(index_label + ':' + row_series.values)
Second attempt:
my_data = df_so.to_numpy()
for idrow, row in enumerate(my_data):
    for idcol, col in enumerate(row):
        if not pd.isnull(col):
            print("Title:" +str(idrow) + ":" + str(idcol) )
Can someone please suggest a way to achieve the desired output?
