I have a DataFrame
:
0 1
0 3.000 5.600
1 1.200 3.456
and for presentation purposes I would like it to be converted to
0 1
0 3 5.6
1 1.2 3.456
What is the elegant way to achieve this (without looping inefficiently over entries of the DataFrame
)?
Or perhaps more generally: is there a way to set pandas
up such that it is always doing this? E.g. one of the pandas
options?
Notice that pd.options.display.float_format = '{:,.0f}'.format
will not work, as it would give a fixed number of decimals, rather than having it vary across entries of the DataFrame
as I indicated above.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…