Skip to content

Series.to_string ignores empty lines at the start/end when index=False #13653

Closed
@alberthdev

Description

@alberthdev

When running to_string on a Series with empty strings at the beginning and end of the Series data, the empty strings are removed from the resulting output. These empty strings should be included to represent the empty data.

Code Sample:

import pandas as pd
pd.Series(["", "Hello", "World", "", "", "Mooooo", "", ""]).to_string(index=False) 

Expected Output:

u'\nHello\nWorld\n     \n     \nMooooo\n\n'

Actual Output:

u'Hello\nWorld\n     \n     \nMooooo'

pd.show_versions():

>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.8.final.0
python-bits: 64
OS: Linux
OS-release: 3.0.101-0.47.67-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: 1.3.6
pip: 1.5.6
setuptools: 3.6
Cython: 0.24
numpy: 1.10.4
scipy: 0.17.0
statsmodels: 0.6.1
xarray: 0.7.2
IPython: 4.2.0
sphinx: 1.2.2
patsy: 0.3.0
dateutil: 2.3
pytz: 2015.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4
matplotlib: 1.5.1
openpyxl: 2.0.4
xlrd: 0.9.0
xlwt: 0.7.4
xlsxwriter: 0.7.3
lxml: 3.4.4
bs4: 4.3.2
html5lib: 1.0b8
httplib2: None
apiclient: None
sqlalchemy: 0.9.7
pymysql: 0.6.2.None
psycopg2: None
jinja2: 2.8
boto: 2.34.0
pandas_datareader: None

Metadata

Metadata

Assignees

Labels

BugIO DataIO issues that don't fit into a more specific labelNeeds TestsUnit test(s) needed to prevent regressionsOutput-Formatting__repr__ of pandas objects, to_stringgood first issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions