I have a python-pandas-dataframe in which first column is user_id and rest of the columns are tags(tag_0 to tag_122). I have the data in the following format:
Why not use np.count_nonzero?
np.count_nonzero
np.count_nonzero(df)
np.count_nonzero(df, axis=0)
np.count_nonzero(df, axis=1)
It works with dates too.