I was looking for a way to find the mean of numerical values based on a certain column. I looked to this link for advice but it requires all values of one column to be the same and I'm sure there's a Pythonic way that would do that for all values that are duplicates.
Here's an example.
data = {
"Name": ["John", "John", "Robert", "Robert", "Cindy", "Cindy", "Sarah", "Sarah"],
"Score": [84, 45, 67, 87, 88, 100, 76, 91]
}
#load data into a DataFrame object:
df = pd.DataFrame(data)
df
I'd like it so there's one row of John with whatever the mean of John is. Same with Robert, Cindy and Sarah.
Thanks!