'python pd.to_excel keep scientific notation format

I have a dataframe which some columns contain numbers. My request is to keep the scientific notation. I am using :

f = final.style.format({
                    'a': "{:.3E}",
                    'b': "{:.3E}",
                    'c': "{:.3E}" }
            )

when I use print(), it shows the correct format which shows scientific notation. when I use pd.to_excel my excel output keeps the decimals.

How should I keep the scientific notation in excel output?

And I input excel have a column that contains both scientific notation and text. when I read the excel the pandas changed the scientific notation to decimals automatically when I convert to scientific notation the text changed to NAN. If I use pd.to_numeric(final['total'], errors='ignore'). the data type is still 'Object'. Then I cannot change back to scientific notation.

Is there any way I can keep the text and scientific notation?

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source