Skip to content

Instantly share code, notes, and snippets.

@EoinTravers
Last active January 2, 2016 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EoinTravers/8320430 to your computer and use it in GitHub Desktop.
Save EoinTravers/8320430 to your computer and use it in GitHub Desktop.

This is a pretty ugly hack, and I apologize to everyone concerned, but I've got around this problem like so:

grouped = data.groupby(['code', 'acc'])
means = grouped.mean()
means['nx'] = [group.nx.mean() for name, group in grouped]
means['ny'] = [group.ny.mean() for name, group in grouped]

group1_correct = means.xs('group1').xs(True)
group1_correct['nx'] # Can only be indexed this way
Out[80]: 
0     0.000000
1     0.000000
2    -0.000013
3    -0.000103
4    -0.000143
5    -0.000160
6    -0.000160
7     0.000717
8     0.001844
9     0.001844
10    0.001844
11    0.001865
12    0.001847
13    0.001824
14    0.001852
...
86     0.883246
87     0.900143
88     0.915110
89     0.929496
90     0.942253
91     0.954429
92     0.964996
93     0.973982
94     0.981439
95     0.987636
96     0.992712
97     0.996104
98     0.998141
99     0.999445
100    0.999834
Length: 101, dtype: float64

I'm so very sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment