Skip to content

pd.Series.to_string(index=False) behavior changed to include leading spaces #28538

Closed
@dauntilus

Description

@dauntilus

This is a change in behavior between 0.23 and 0.25.

On 0.23.0

In [10]: s=pd.Series(['a','b','c'])
       : s.to_string(index=False)
Out[10]: 'a\nb\nc'

On 0.25.0

In [2]: s=pd.Series(['a','b','c'])
      : s.to_string(index=False)
Out[2]: ' a\n b\n c'

Particularly strange with a series of length 1

In [8]: s=pd.Series(['a'])
      : s.to_string(index=False)
Out[8]: ' a'

There is always exactly 1 leading space regardless of how many characters the index would have taken. The same behavior appears in DataFrame.to_string.

Is this an intended change in behavior? I'm happy to look into identifying the cause if it is not intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions