python replace spaces with underscore in column code example
Example 1: python replace space with underscore
mystring.replace(" ", "_")
Example 2: replace all spacec column with underscore in pandas
import pandas as pd
# remove spaces in columns name
df.columns = df.columns.str.replace(' ','_')