Reputation: 1
I am summarising a variable 'CSC130' using an aggregation dictionary and have a question around how to get a 25th percentile, 75th percentile values.
The quantile summary function is mentioned in the documentation but I can't see the syntax for how to use it?
How would I add a line to get the 25th percentile value for 'CSC130' using this dictionary
many thanks!
aggregations = {
'CSC130': {
'CSC130_sum': 'sum',
'CSC130_mean': 'mean',
'CSC130_min': 'min',
'CSC130_max': 'max',
'CSC130_count': 'count',
'CSC130_size': 'size',
'CSC130_range': lambda x: max(x) - min(x),
'CSC130_npmean': lambda x: np.mean(x),
'CSC130_median': 'median'
}
}
sumry = df.groupby(['POSTCODE']).agg(aggregations)
Upvotes: 0
Views: 646
Reputation: 5860
The syntax is simply
yourseries.quantile(yourquantile)
So just add these lines -
'CSC130_25quant': lambda x : x.quantile(0.25)
'CSC130_75quant': lambda x : x.quantile(0.75)
Upvotes: 1