I understand this is a repeat question, but I can't find a succinct answer (or as a newbie, I can't succinctly understand an answer).
I have 2 sets of lists that I want to reference (separately) within a function:
cols = ['snow','ice']
metrics ['feet','inches']
def avg(df):
df1 = df.groupby(cols[0], as_index=False)[metrics[0]].mean()
.sort_values(metrics[0]).drop_duplicates()
return df1
avg(df)
This runs properly. How can I add an additional metric index (and if not, why not and what's the best approach)? Like this:
def avg(df):
df1 = df.groupby(cols[0], as_index=False)[metrics[0,1]].mean()
.sort_values(metrics[0]).drop_duplicates()
return df1
avg(df)
Thank you