ddionrails / testsuite

DDI on Rails - testsuite
0 stars 0 forks source link

Weighted frequencies #9

Closed mhebing closed 8 years ago

mhebing commented 8 years ago
import pandas as pd
import numpy as np

x = pd.DataFrame(dict(a = [1, 2, 1, 2], w = [0.5, 0.5, 1, 10]))
x.a.value_counts()
x.pivot_table(index="a", values="w", aggfunc=np.sum)