In the dataset, the column "Erf Size" has entries like 1 733 and 1 539 etc. Note that the Dtype of this "Erf Size" column is object.
I would like to join these 1 733 and 1 539 into 1733 and 1539 etc. original dataset
CodePudding user response:
I think you can fix this with pd.to_numeric
. This will change the data type to a number value and I expect it to remove the space.
Or else you can try:
df1['Erf Size'].str.strip()
that will remove the space, which will work in your dataset as it's an object.
CodePudding user response:
I would use list comprehension to clean string and then if you want to can convert dtype to numeric value:
df['Erf Size'] = [x.replace(' ', '').replace('.', '').replace(',', '') for x in df['Erf Size']]