[Python] Formatar percentagem em python

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    Como devo formatar a percentagem para este exemplo?

    import pandas as pd
    flights = pd.read_csv('data/flights_until_june.csv', sep=',')
    sum_null = flights.isnull().sum()
    sum_null.sort_values(ascending=False, inplace=True)
    total = flights.shape[0]
    percentage = round(sum_null/total * 100, 2)
    print(percentage)
    print('{:2%}'.format(percentage))

    Continue reading...

Compartilhe esta Página