adding pandas solution as a reference to the 'means of subsets' exercise
This commit is contained in:
parent
497f204914
commit
9e3eb1d1dd
@ -1467,7 +1467,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())"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -714,6 +714,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? (★★★)
|
||||
|
Loading…
Reference in New Issue
Block a user