Is there a way to omit some of the output from the pandas describe? This command gives me exactly what I want with a table output (count and mean of executeTime’s by a simpleDate)
JavaScript
x
2
1
df.groupby('simpleDate').executeTime.describe().unstack(1)
2
However that’s all I want, count and mean. I want to drop std, min, max, etc… So far I’ve only read how to modify column size.
I’m guessing the answer is going to be to re-write the line, not using describe, but I haven’t had any luck grouping by simpleDate and getting the count with a mean on executeTime.
I can do count by date:
JavaScript
1
2
1
df.groupby(['simpleDate']).size()
2
or executeTime by date:
JavaScript
1
2
1
df.groupby(['simpleDate']).mean()['executeTime'].reset_index()
2
But can’t figure out the syntax to combine them.
My desired output:
JavaScript
1
6
1
count mean
2
09-10-2013 8 20.523
3
09-11-2013 4 21.112
4
09-12-2013 3 18.531
5
..
6
Advertisement
Answer
Describe returns a series, so you can just select out what you want
JavaScript
1
34
34
1
In [6]: s = Series(np.random.rand(10))
2
3
In [7]: s
4
Out[7]:
5
0 0.302041
6
1 0.353838
7
2 0.421416
8
3 0.174497
9
4 0.600932
10
5 0.871461
11
6 0.116874
12
7 0.233738
13
8 0.859147
14
9 0.145515
15
dtype: float64
16
17
In [8]: s.describe()
18
Out[8]:
19
count 10.000000
20
mean 0.407946
21
std 0.280562
22
min 0.116874
23
25% 0.189307
24
50% 0.327940
25
75% 0.556053
26
max 0.871461
27
dtype: float64
28
29
In [9]: s.describe()[['count','mean']]
30
Out[9]:
31
count 10.000000
32
mean 0.407946
33
dtype: float64
34