Good morning, could you help me with...
I have the Following DataFrame
fecha Medicamento Dosis ClaseServicio
0 2022-11-10 Vancomicina IV 4000.00 HOSPITALIZACION
1 2022-11-12 Vancomicina IV 2.00 HOSPITALIZACION
2 2022-11-01 Ceftriaxona IV 10.00 HOSPITALIZACION
3 2022-11-10 Ceftriaxona IV 10.00 HOSPITALIZACION
4 2022-11-10 Ertapenem IV 20.00 HOSPITALIZACION
5 2022-11-10 Ertapenem IV 20.00 HOSPITALIZACION
6 2022-11-10 Cefepime IV 9.00 CUIDADO CRITICO
7 2022-11-10 Cefepime IV 9.00 CUIDADO CRITICO
8 2022-11-10 Meropenem IV 30.00 HOSPITALIZACION
9 2022-11-10 Meropenem IV 15.00 CUIDADO CRITICO
10 2022-11-10 Piperacilna/tazobactam IVIV 3.00 CUIDADO CRITICO
First it should, Separate the rows by type of value Column "ClassService" , which are "HOSPITALIZATION" or "CRITICAL CARE", Second it should, it should add the Dose Column "Dose" of each type of Medication of Column "Medication"
All this to have the following output. I understand that some steps may be unnecessary Example:
This for each month you have.
I have tried in the following way:
CrossTab function
pd.crosstab(df_filtro.PAV ,[ df_filtro.ClaseServicio], aggfunc = "sum", values = df_filtro.Dosis)
pd.crosstab([df_filtro.fecha,df_filtro.PAV ],[ df_filtro.ClaseServicio], aggfunc = "sum", values = df_filtro.Dosis)
But I don't know how to solve the last thing that shows me per month the sum of each PAV/Medication.
I'd appreciate your help. Cheers