how to remove unwanted spaces of a column in python code example
Example 1: pandas replace column name spaces with underscore
import pandas as pd
# remove spaces in columns name
df.columns = df.columns.str.replace(' ','_')
Example 2: python - remove exta space in column
df.Name = df.Column_Name.replace('\s+', ' ', regex=True)