pandas.set_eng_float_format — pandas 3.0.0rc0+33.g1fd184de2a documentation (original) (raw)
pandas.set_eng_float_format(accuracy=3, use_eng_prefix=False)[source]#
Format float representation in DataFrame with SI notation.
Sets the floating-point display format for DataFrame objects using engineering notation (SI units), allowing easier readability of values across wide ranges.
Parameters:
accuracyint, default 3
Number of decimal digits after the floating point.
use_eng_prefixbool, default False
Whether to represent a value with SI prefixes.
Returns:
None
This method does not return a value. it updates the global display format for floats in DataFrames.
See also
Set the value of the specified option or options.
Reset one or more options to their default value.
Examples
df = pd.DataFrame([1e-9, 1e-3, 1, 1e3, 1e6]) df 0 0 1.000000e-09 1 1.000000e-03 2 1.000000e+00 3 1.000000e+03 4 1.000000e+06
pd.set_eng_float_format(accuracy=1) df 0 0 1.0E-09 1 1.0E-03 2 1.0E+00 3 1.0E+03 4 1.0E+06
pd.set_eng_float_format(use_eng_prefix=True) df 0 0 1.000n 1 1.000m 2 1.000 3 1.000k 4 1.000M
pd.set_eng_float_format(accuracy=1, use_eng_prefix=True) df 0 0 1.0n 1 1.0m 2 1.0 3 1.0k 4 1.0M
pd.set_option("display.float_format", None) # unset option