I have generated a pandas dataframe using below code where an example sequence column is like '0-0-0-1-0-0-2-0-0-0-0' I split the sequence string into different columns
df = DataFrame(data, columns = ['id', 'sequence'])
print(df.sequence.str.split("-", expand=True))
0 1 2 3 4 5 6 7 8 9
0 0 0 0 1 0 0 2 0 0
1 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0
3 0 1 0 0 2 0 0 0 0
4 0 0 0 3 0 0 0 0 0
5 0 0 0 0 0 4 0 0 0
If I want to count the number of occurences of 0 in each column, how do I do it?
I tried something like this print df[df.education == '9th'].count()
based on Python Pandas Counting the Occurrences of a Specific value but I don't have column names appropriately, and I am not sure how to do it.
Can you please help.