I want to convert a column that has values like 1234567.89 to 1,234,567.89. Can someone help me with this.
to_numeric() The best way to convert one or more columns of a DataFrame to numeric values is to use pandas. to_numeric() . This function will try to change non-numeric objects (such as strings) into integers or floating-point numbers as appropriate.
Split column by delimiter into multiple columns Apply the pandas series str. split() function on the “Address” column and pass the delimiter (comma in this case) on which you want to split the column. Also, make sure to pass True to the expand parameter.
You can format your column by doing this:
df['new_column_name'] = df['column_name'].map('{:,.2f}'.format)
But keep in mind that the new column will contain strings, not floats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With