I have a large data frame looking like this.
| Name | Gender | Count | Probability |
|---|---|---|---|
| James | M | 12345 | 0.012313 |
| John | M | 12334 | 0.012314 |
| Robert | M | 12300 | 0.0124 |
| Michael | M | 12222 | 0.13 |
| William | M | 12121 | 0.123131 |
| Mary | F | 10002 | 0.123112 |
I was wondering how i can get the sum of the counts of all of the names that start with each letter of the alphabet in the dataframe and create a new dataframe that looks like
Name Count A 22222 B 44444 C 66666 https://stackoverflow.com/questions/67249222/how-to-find-the-sum-of-a-column-based-on-another-column-and-put-it-into-a-new-da April 25, 2021 at 10:30AM
没有评论:
发表评论