I am begginer in python.
I have three datasets that have a similar structure and I want to perform the same process for each one and save the results. My code run well but it only save the results for the last one base in bases. ¿How can I save the results in three different datasets?
My code looks like:
bases = [base1, base1_a, base1_b]
for base in bases:
base = base.groupby(["Cliente_id", "Periodo_id"]).agg({"monto_2018": ["sum", "mean", "min", "max"]}).reset_index().round(1)
base.columns = base.columns.get_level_values(1)
base = base.set_axis(["Cliente_id", "Periodo_id", 'sum_v', 'mean_v', 'min_v', "max_v"], axis=1, inplace=False)
for base in bases: print(base)
I think you are already achieving what you want, with this you can verify it