For example, I have a DataFrame named a. I want to count the element of each row.
import numpy as np
a=pd.DataFrame({'A1':['financial','game','game'],'A2':['social','food','sport'],'A3':['social','sport','game']})
Input:
A1 A2 A3
0 financial social social
1 game food sport
2 game sport game
Expected:
financial food game social sport
0 1 0 0 2 0
1 0 1 1 0 1
2 0 0 2 0 1
Hopefully for help, thanks!