this is my first post here.
I don't exactly know how to formulate this question without an example, so it's hard to search for an answer. Anyway, I have a DataFrame that looks like this (with more columns and thousands of rows):
df = pd.DataFrame({"A": [1, 0, 0], "B": [0, 0, 1], "C": [0, 1, 0]})
I would like to create additional column eg. "Type", where value of each row would be column name of the column that contains 1 in this row. For example:
df = pd.DataFrame({"A": [1, 0, 0], "B": [0, 0, 1], "C": [0, 1, 0], "Type": ["A", "C", "B"]})
I hope this makes sense.
Thanks, Chris