Calculating the Standard Deviation by category using Python I have a datset with Scores and Categories and I would like to calculate the Standard Deviation of these scores, per category. The data look something like this:

Category    Score    
AAAA        1
AAAA        3
AAAA        1
BBBB        1
BBBB        100
BBBB        159
CCCC        -10
CCCC        9


What I would then like is the Standard Deviation of each Category. I know that with numpy I can use the following:

numpy.std(a)


But the example I can find only have this relating to a list and not a range of different categories in a DataFame.
You can easily do this using pandas:

import pandas as pd
import numpy as np

df = pd.DataFrame([["AA", 1], ["AA", 3], ["BB", 3], ["CC", 5], ["BB", 2], ["AA", -1]])
df.columns = ["Category", "Score"]
print df.groupby("Category").apply(np.std)