Merge pull request #26 from ibah/master

adding pandas solution as a reference to the 'means of subsets' exercise
This commit is contained in:
Nicolas P. Rougier 2016-10-04 20:59:48 +02:00 committed by GitHub
commit 66de752cad
2 changed files with 9 additions and 1 deletions

View File

@ -1470,7 +1470,11 @@
"D_sums = np.bincount(S, weights=D)\n",
"D_counts = np.bincount(S)\n",
"D_means = D_sums / D_counts\n",
"print(D_means)"
"print(D_means)\n",
"\n",
"# Pandas solution as a reference due to more intuitive code\n",
"import pandas as pd\n",
"print(pd.Series(D).groupby(S).mean())"
]
},
{

View File

@ -718,6 +718,10 @@ D_sums = np.bincount(S, weights=D)
D_counts = np.bincount(S)
D_means = D_sums / D_counts
print(D_means)
# Pandas solution as a reference due to more intuitive code
import pandas as pd
print(pd.Series(D).groupby(S).mean())
```
#### 69. How to get the diagonal of a dot product? (★★★)