Skip to content

ENH : GH11729 added index parameter in series to_string #11750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2015

Conversation

varunkumar-dev
Copy link
Contributor

Fixes #11729
Please Review .

@@ -126,14 +126,15 @@ def to_string(self):
class SeriesFormatter(object):

def __init__(self, series, buf=None, length=True, header=True,
na_rep='NaN', name=False, float_format=None, dtype=True,
max_rows=None):
na_rep='NaN', index=True, name=False, float_format=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these in the same order as the DataFrameFormatter ?

@jreback
Copy link
Contributor

jreback commented Dec 4, 2015

pls add a whatsnew note (enhancements is ok)

@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string Compat pandas objects compatability with Numpy or Python functions labels Dec 4, 2015
@jreback jreback added this to the 0.18.0 milestone Dec 4, 2015
@jreback
Copy link
Contributor

jreback commented Dec 9, 2015

@varun-kr can you update

@varunkumar-dev
Copy link
Contributor Author

@jreback Updated code . Please review .

It seems that there is some problem with the build .
ERROR: test_get_all_data (pandas.io.tests.test_data.TestYahooOptions) is failing for many builds.

@jreback
Copy link
Contributor

jreback commented Dec 10, 2015

just push again; the option tests occasionally fail

@varunkumar-dev
Copy link
Contributor Author

@jreback Done.

s= Series([1, 2, 3, 4])
result = s.to_string(index=False)
expected = (u(' 1\n') +
' 2\n' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche does this look right? (e.g. I know we add a space, but seems odd with no index....)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems more logical to me that the space is not there if no index is added.

But, DataFrame.to_string also does this:

In [13]: print df.to_string()
   a  b  c
0  1  b  1
1  1  b  2
2  2  b  3
3  2  a  4

In [14]: print df.to_string(index=False)
 a  b  c
 1  b  1
 1  b  2
 2  b  3
 2  a  4

Of course not necessarily a reason to do it here as well

jreback added a commit that referenced this pull request Dec 12, 2015
ENH : GH11729 added index parameter in series to_string
@jreback jreback merged commit faa6cc7 into pandas-dev:master Dec 12, 2015
@jreback
Copy link
Contributor

jreback commented Dec 12, 2015

@varun-kr thanks!

can you open an issue to re-examine whether passing index=False should add those leading spaces (I think not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants