I have df with some string values.
so = pd.DataFrame({
"col1": ["row0", "row1", "row2"],
"col2": ["A", "B", "C"],
"col3": ["A", "A", "B"],
"col4": ["B", "A", "B"],
})
I need to create pivot table where:
- index is values from column "col1"
- columns are unique values from columns ['col2':'col4']
- values at the intersection are count of column name matches for every row
For my example, the answer should be:
Please help... thank you in advance