For example, I have a data frame like this:
id 0 1 2 3 4 5
0 1 a b null c null null
1 2 null a null d e null
2 3 d null c null a null
3 4 null null d null b e
4 5 c a e b null b
And I wanna get a data frame like:
id null a b c d e
0 1 3 1 1 1 0 0
1 2 3 1 0 0 1 1
2 3 3 1 0 1 1 0
3 4 3 0 1 0 1 1
4 5 1 1 2 1 0 1
How to do that? Thanks!
Edit:
I tried this
aoi_data = pd.get_dummies(aoi.set_index('userId').stack()).sum(level=0)
That's it!