1

I have a problem with a pandas Dataframe that amongst other things contains the number of rooms in an apartment (type String).

This data consists of a unicode character u"\u00BD" (https://www.fileformat.info/info/unicode/char/00bd/index.htm).

How do i effectively replace this character with decimal values so that instead of the unicode character the data will read 2.5, 3.5, 4.5 etc (Still String format).

It currently looks like this: 2½, 3½, 4½ etc And i want the values in the column to be 2.5, 3.5, 4.5 etc.

2

1 Answer 1

1

You can fix your column with:

df['rooms'] = df['rooms'].str.replace("½", ".5")

To make it a float:

df['rooms'] = df['rooms'].str.replace("½", ".5").apply(float)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.