Mean, Median, and mode of a list of values (SCORE) given a certain zip code for every year
问题 I want to find the mean, median and mode value for each year given a specific ZIP code how can I achieve this, I already read the data from CSV file and convert it to json file and define it as DataFrame my data sample is not limited to the following table it's larger 回答1: Use SciPy.mstats: In [2295]: df.DATE = pd.to_datetime(df.DATE).dt.year In [2291]: import scipy.stats.mstats as mstats In [2313]: def mode(x): ...: return mstats.mode(x, axis=None)[0] ...: In [2314]: df.groupby(['DATE',