Python 空格值处理

from pandas import read_csv

df = read_csv(

'D:\\PDA\\4.5\\data.csv'

)


Python 空格值处理_第1张图片

newName = df['name'].str.lstrip() #清除字符串左边空格变量


Python 空格值处理_第2张图片

newName = df['name'].str.rstrip() #清除字符串右边的变量


Python 空格值处理_第3张图片

newName = df['name'].str.strip()#清除左右字符串变量


Python 空格值处理_第4张图片

df['name'] = newName


Python 空格值处理_第5张图片

你可能感兴趣的:(Python 空格值处理)