Hello Please, in Python 3 pandas I am creating this dataframe with the sum of another dataset:
total = cand_doacoes.groupby(['CPF_candidato', 'Nome_candidato', 'Cargo']).Valor.sum().reset_index()
total = total[(total['Cargo'] == 'Deputado Federal')]
total.info()
<class 'pandas.core.frame.DataFrame'> Int64Index: 5516 entries, 0 to 19707 Data columns (total 4 columns): CPF_candidato 5516 non-null int64 Nome_candidato 5516 non-null object Cargo 5516 non-null object Valor 5516 non-null object dtypes: int64(1), object(3) memory usage: 150.8+ KB
The Value column I wish to round to two decimal places, so I put this command:
total.round({'Valor': 2})
But it did not work:
CPF_candidato Nome_candidato Cargo Valor 0 1608657 STEFANO AGUIAR DOS SANTOS Deputado Federal 10000,00548,501675,00500,00400,003750,0010000,... 1 2498316 HENRIQUE EDUARDO BARROSO MOREIRA Deputado Federal 240,00124,0025,8699,79285,71245,00 6 7331304 CARLOS MAURO CABRAL BENEVIDES Deputado Federal 3501,4010000,00100000,00200000,00100000,003000...
Does anyone know how to do it?