Pandas Column Content Editing

Pandas Column Content Editing

Problem Description:

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.

Solution – 1

df['DataFrame Column'] = df['DataFrame Column'].str[:-1].astype(float)/100
Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject