Anyone knows how to pass arguments in a groupby.agg() with multiple functions?
Bottom line, I would like to use it with a custom function, but I will ask my question using a built-in function needing an argument.
Assuming:
import pandas as pd
import numpy as np
import datetime
np.random.seed(15)
day = datetime.date.today()
day_1 = datetime.date.today() - datetime.timedelta(1)
day_2 = datetime.date.today() - datetime.timedelta(2)
day_3 = datetime.date.today() - datetime.timedelta(3)
ticker_date = [('fi', day), ('fi', day_1), ('fi', day_2), ('fi', day_3),
('di', day), ('di', day_1), ('di', day_2), ('di', day_3)]
index_df = pd.MultiIndex.from_tuples(ticker_date, names=['lvl_1', 'lvl_2'])
df = pd.DataFrame(np.random.rand(8), index_df, ['value'])
How would I do this:
df.groupby('lvl_1').agg(['min','max','quantile'])
with, as argument for 'quantile':
q = 0.22