Jun-12-2018, 07:49 PM
One last note here as I have been experimenting with pandas since Volcano pointed us in that direction.
https://pandas.pydata.org/pandas-docs/st...ggregation
It is designed such that you don't even need the loop to apply functions to the dataframe:
https://pandas.pydata.org/pandas-docs/st...ggregation
It is designed such that you don't even need the loop to apply functions to the dataframe:
df = pd.DataFrame(x) print(df.groupby(df[0]).agg(max))
Output: 1
0
126.0 23.0
129.0 125.0
132.0 41.0
142.0 76.0
In fact you can apply multiple functions in one operation and it even names the columns for you automatically:df = pd.DataFrame(x) print(df.groupby(df[0]).agg([max, min, sum, np.mean]))
Output: 1
max min sum mean
0
126.0 23.0 1.0 53.0 8.833333
129.0 125.0 1.0 293.0 36.625000
132.0 41.0 1.0 44.0 14.666667
142.0 76.0 6.0 82.0 41.000000