0

I was wondering what method is best for changing contents in the whole column in my dataframe. Part of my dataframe has the column "Percentage" and the contents in that column labeled as "#%". Here, I want to adjust the whole column from percentage to decimal numbers. For instance, 80% to 0.80 and 42% to 0.42. What would be the best way to make this adjustment?

Thanks in advance.

  • have a look [here](https://stackoverflow.com/questions/25669588/convert-percent-string-to-float-in-pandas-read-csv) for one way in pandas and [here](https://stackoverflow.com/questions/12432663/what-is-a-clean-way-to-convert-a-string-percent-to-a-float) for more ways in general – Rabinzel Nov 21 '22 at 06:17

1 Answers1

0
df['DataFrame Column'] = df['DataFrame Column'].str[:-1].astype(float)/100
Iddo Sadeh
  • 133
  • 6