Merge pull request #26 from ibah/master
adding pandas solution as a reference to the 'means of subsets' exercise
This commit is contained in:
@@ -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? (★★★)
|
||||
|
||||
Reference in New Issue
Block a user