I am currently using the following logic to round to round to 2 decimal places:
billables_all["Parts Charged"] = billables_all["Parts Charged"].fillna(0).round(2)
billables_all["Labor Charged"] = billables_all["Labor Charged"].fillna(0).round(2)
billables_all["Travel Charged"] = billables_all["Travel Charged"].fillna(0).round(2)
billables_all["Invoice Amount"] = billables_all["Invoice Amount"].fillna(0).round(2)
billables_all["USD Amount"] = billables_all["USD Amount"].fillna(0).round(2)
However, in the output it appears that it cuts off the 0's.
Is there a way to have the results output show 0.00 and 397.00?
Thanks!
CodePudding user response:
In a format string you can set the number of decimal places:
billables_all["Parts Charged"] = f'{billables_all["Parts Charged"]:.2f}'
CodePudding user response:
You can try
billables_all["Parts Charged"] = billables_all["Parts Charged"].apply('{0:.2f}'.format)