Skip to content

Instantly share code, notes, and snippets.

@nhatbui
nhatbui / count_unique.py
Last active November 20, 2015 05:55
Count Unique from Pandas DataFrame
import pandas as pd
d = {
'a': ['1','1','2','2','2','3'],
'b': ['green', 'blue','yellow','yellow','blue','green']
}
df = pd.DataFrame.from_dict(d)
df_count = pd.crosstab(df['a'], df['b'])