I have a pandas df with multiple rows, 5k+ and approximately 10 columns True/False. In each of the rows, only one of the column's entries will be True and the remaining 9 false.
# Import library
import pandas as pd
# Create dictionary and convert to pd DF
test = {"col1":[True, False, True, True, False],
        "col2":[False, True, False, False, True]}
test = pd.DataFrame(test)
# Show case a dataframe
print(test)
The dataframe should look like
    col1    col2
0   True    False
1   False   True
2   True    False
3   True    False
4   False   True|
I am hoping to return an array with the following values:
output_array = ['col1','col2','col1','col1','col2']
I'm stuck and I know I should probably use some sort of apply method and index the 10 columns, but I am not sure on the best way to screen the subset of elements of a row for True and return the column. Any help much appreciated and thank you!
 
     
    