Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

replace all spacec column with underscore in pandas

import pandas as pd 

# remove spaces in columns name
df.columns = df.columns.str.replace(' ','_')
Comment

pandas replace space with underscore in column names

df.rename(columns=lambda x: x.strip().replace(" ", "_"), inplace=True)
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib bar chart from dictionary 
Python :: code how pandas save csv file 
Python :: python write text file 
Python :: yyyy-mm-dd hh:mm:ss.0 python 
Python :: matplotlib log 
Python :: plotly hide legend 
Python :: python simple server 
Python :: python flip a coin 
Python :: export image png python 
Python :: pd if value delete row 
Python :: convert column to numeric pandas 
Python :: how to sort by length python 
Python :: export multiple python pandas dataframe to single excel file 
Python :: how to find python location in cmd 
Python :: verify django has been installed 
Python :: horizontal bar chart with seaborn 
Python :: check if special character in string python 
Python :: how to strip quotation marks in python 
Python :: download python on wsl 
Python :: libGLU.so.1: cannot open shared object file: No such file or directory 
Python :: zip list to dictionary python 
Python :: The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. 
Python :: how to install numpy 
Python :: python border 
Python :: numpy array with random numbers 
Python :: pandas uniqe values in the columns 
Python :: get directory of file python 
Python :: pandas change last row 
Python :: jupyter notebook dark theme 
Python :: python convert number to base 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =