Back to questions
JuniorTheoryCommon
What does this program print?
import pandas as pd
df = pd.DataFrame({
"team": ["a", "a", "a", "b", "b"],
"salary": [100, 110, 600, 120, 130],
})
med = df.groupby("team")["salary"].median()
print(med.to_dict()){'a': 110.0, 'b': 125.0}
- Expecting
270.0for teama: that is the mean, which the outlier600drags up; the median is the middle of100, 110, 600, so it is110.0. - Expecting
130.0for teamb: with an even number of values the median is the mean of the two central ones,(120 + 130) / 2, so125.0.
- Which salary figure would you report for team
aas typical, and why? - What would the median of team
abecome if600were replaced by6000?