Skip to content

Strip columns/column names in data frame of white spaces #14460

Open
@rahulporuri

Description

@rahulporuri

This is more of a question than a bug.

A small, complete example of the issue

while opening a data file similar to

 a , b , c , d 
 1 , 2 , 3 , 4 
 5 , 6 , 7 , 8 

using

python -c "import pandas; df = pandas.read_table('unstripped_data.csv', sep=','); print df.columns"

Observed Output

Index([u' a ', u' b ', u' c ', u' d '], dtype='object')

Expected Output

Index([u'a', u'b', u'c', u'd'], dtype='object')

We expected that the column names/columns be stripped of white spaces.
Apologies for the noise if this has already been reported or is being addressed.

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 16.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.19.0
nose: 1.3.7
pip: 8.1.2
setuptools: 23.1.0
Cython: 0.24
numpy: 1.10.4
scipy: None
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.4.1
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: 2.4.0
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: 3.6.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
boto: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions