Answers for "pandas currency conversion"

4

pd set output to currency

#make large numbers more readable by adding commas
pd.options.display.float_format = '{:,}'.format
# Example
123456789.12345 -> 123,456,789.12345

#this adds commas and limits decimals to 2 places
pd.options.display.float_format = '{:,.2f}'.format
# Example
123456789.12345 -> 123,456,789.12

#this adds the dollar sign to the front
pd.options.display.float_format = '${:,.2f}'.format
# Example
123456789.12345 -> $123,456,789.12
Posted by: Guest on December-15-2020
0

pandas currency to numbe

df[df.columns[1:]] = df[df.columns[1:]].replace('[$,]', '', regex=True).astype(float)
Posted by: Guest on February-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language