I want to get the frequency count of strings within a column. One one hand, this is similar to collapsing a dataframe to a set of rows that only reflects the strings in the
Another solution using groupby and value_counts
df.unstack().groupby(level=0).value_counts().unstack().T.fillna(0)
Out[]:
2017-08-09 2017-08-10
active_1 2.0 3.0
active_1-3 1.0 0.0
active_3-7 1.0 1.0
pre 1.0 1.0
Or avoiding the last call to fillna
df.unstack().groupby(level=0).value_counts().unstack(fill_value=0).T