Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas delete spaces

df.columns = df.columns.str.strip()
Comment

pandas delete spaces

df.columns = df.columns.str.rstrip()
Comment

pandas strips spaces in dataframe

df_obj = df.select_dtypes(['object'])
print (df_obj)
0    a  
1    c  

df[df_obj.columns] = df_obj.apply(lambda x: x.str.strip())
print (df)

   0   1
0  a  10
1  c   5
Comment

pandas delete spaces

df.columns = df.columns.str.lstrip()
Comment

pandas remove whitespace

str.strip() method
Comment

remove whitespace from data frame

# importing library
import pandas as pd
 
# reading csv file and at a same time using skipinitial attribute which will remove extra space
df = pd.read_csv('student_data.csv', skipinitialspace = True)
 
# printing dataset
print(df)
Comment

PREVIOUS NEXT
Code Example
Python :: get biggest value in array python3 
Python :: python run a system command 
Python :: get stock data in python 
Python :: python open file relative to module 
Python :: add element to list python at index 
Python :: scientific notation matplotlib python 
Python :: python tempfile 
Python :: python ceil 
Python :: latency discord.py 
Python :: pandas to excel add another sheet in existing excel file 
Python :: find a file in python 
Python :: django rest framework default_authentication_classes 
Python :: python datetime from string 
Python :: get all h1 beautifulsoup 
Python :: compute eigenvalue python 
Python :: data dictionary python into numpy 
Python :: column.replace 
Python :: python string to hex 
Python :: plt.xticks 
Python :: download a file from url python 
Python :: if django 
Python :: weekday pandas 
Python :: Creating a list with list comprehensions 
Python :: how to read a text file from url in python 
Python :: ipywidegtes dropdown 
Python :: how to create obtain any random 3 items of list in python 
Python :: password text in entry in tkinter 
Python :: add dir to path python 
Python :: find the first occurrence of item in a list in python 
Python :: how to remove b in front of python string 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =