human
How to replace the white space in a string in a pandas dataframe?
assistant
Here is some code to replace white spaces in dataframe `df` with '_'

df.replace(' ', '_', regex=True)

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.