Remove trailing .0 from values in Python
Just use df.apply and then use lambda with "{:.2f}".format(x) to limit it to 2 digits after the 0
When loading in an excel file, Pandas is ingesting a value (1735582) into a float value of (1735582.0). Subsequently, when importing the file to SQL, the value is ingested as a truncated scientific notation value (1.73558e+06), thereby rendering the value useless.
My first thought was to trim any trailing '.0' from all values, and then see if the import goes smoothly to retain the native values.
I have attempted to use the dataframe.replace to identify values across the entire dataframe that have a trailing '.0', but have no come up with the right solution:
df_update = df.replace(to_replace ='\.\[0]$', value = '', regex = True)
I need a way to 1) ingest the values without the trailing '.0', 2) remove the trailing '.0', or 3) prevent to_sql from outputting the values as truncated scientific notation.