Skip to content

to_string() returning None #232

Closed
Closed
@PhE

Description

@PhE

DataFrame.to_string() is printing directly to console and not returning a string :

>>> import pandas
>>> df = pandas.DataFrame(range(5))
>>> df
   0
0  0
1  1
2  2
3  3
4  4
>>> view_repr = repr(df)
>>> view_to_string = df.to_string()
   0
0  0
1  1
2  2
3  3
4  4
>>> view_repr == view_to_string
False

For large DataFrame, we have to use to_string() to get a tabular view.
But the return value is not set (None) and can't be retrieved :

>>> view_repr
'   0\n0  0\n1  1\n2  2\n3  3\n4  4\n'
>>> view_to_string
>>>

It would be usefull to get a string (or StringIO) returned by DataFrame.to_string()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions