def calcular_estadisticas(descargas: pd.DataFrame) -> pd.DataFrame:
descargas = pd.DataFrame(descargas)
global new_df
new_df['COMENTARIOS'] = np.where(new_df['COMENTARIO'] == True, 1, 0)
new_df = new_df[new_df['PAGO'] != 0]
new_df['PAGO2'] = new_df['PAGO']
new_df['PAGO3'] = new_df['PAGO']
new_df['ESTRELLAS2'] = new_df['ESTRELLAS']
new_df = new_df.groupby('MODELO').agg(
{'USUARIO': 'count', 'PAGO': 'mean', 'PAGO2': 'max', 'PAGO3': 'min', 'ESTRELLAS': 'mean', 'ESTRELLAS2': 'std',
'COMENTARIOS': 'sum'})
new_df = new_df.rename(columns={'USUARIO': 'CANTIDAD', 'PAGO': 'PROMEDIO', 'PAGO2': 'MAXIMO', 'PAGO3': 'MINIMO',
'ESTRELLAS': 'ESTRELLAS', 'ESTRELLAS2': 'DESV. ESTRELLAS',
'COMENTARIOS': 'COMENTARIOS'})
new_df['DESV. ESTRELLAS'] = new_df['DESV. ESTRELLAS'].fillna(0)
new_df['PROMEDIO'] = round(new_df['PROMEDIO'], 2)
new_df['ESTRELLAS'] = round(new_df['ESTRELLAS'], 2)
new_df['DESV. ESTRELLAS'] = round(new_df['DESV. ESTRELLAS'], 2)
new_df['MAXIMO'] = round(new_df['MAXIMO'], 2)
new_df['MINIMO'] = round(new_df['MINIMO'], 2)
return new_df