Why can't pandas dataframe output column values be aligned separately?

when importing the csv file to clean the Filter file, it was found that a column of output values were not aligned, resulting in a duplicate data count in value_counts ()

clipboard.png

clipboard.png
how should I handle this situation, and is there any way to align these values?

Jun.11,2021

these values must have spaces. Try to get rid of the blanks.

df["Renovation"].str.strip().values_counts()

the problem of inconsistent data format can be solved by the following methods:

df['Renovation'] = df['Renovation'].apply(lambda x : x.strip())

you can also choose lstrip and rstrip

as needed.
Menu