[Python] How to save values to a CSV file in exponent in python

Discussão em 'Python' iniciado por Stack, Dezembro 9, 2024.

  1. Stack

    Stack Membro Participativo

    For a project in Python i have to read float values from an excel file and save it as exponential values in a CSV file by using Pandas. When i print the values, they are shown as exponent, but when i open the CSV file afterwards, i get only float values. How to save them as exponential values?

    Datas = pd.read_excel(Dateiname_Excel, sheet_name = "Tabelle1", header=0)
    print (Datas)

    pd.set_option('display.float_format', '{:.1E}'.format)
    print (Datas)

    Datas_2 = Datas.astype(float, '{:.1E}'.format)
    Datas_2["Pos"] = Datas_2["Pos"].astype(int)

    Datas_2.to_csv(Dateiname_CSV, index = None, header = HeaderList)
    print (Datas_2)

    CSV_File.close()

    Continue reading...

Compartilhe esta Página