Skip to content
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

Exception calling to_string on empty Series #488

Closed
craustin opened this issue Dec 14, 2011 · 3 comments
Closed

Exception calling to_string on empty Series #488

craustin opened this issue Dec 14, 2011 · 3 comments
Labels
Milestone

Comments

@craustin
Copy link

from pandas import Series
s = Series({})
s.to_string()

pandas\core\series.pyc in to_string(self, buf,
na_rep, float_format, nanRep)
460 na_rep = nanRep
461
--> 462 the_repr = self._get_repr(float_format=float_format, na_rep=na_rep)
463 if buf is None:
464 return the_repr

pandas\core\series.pyc in _get_repr(self, name, print_header, length, na_rep, float_format)
481 string_index = index.format()
482
--> 483 maxlen = max(len(x) for x in string_index)
484 padSpace = min(maxlen, 60)
485

ValueError: max() arg is an empty sequence

@wesm
Copy link
Member

wesm commented Dec 15, 2011

Not obvious what to_string should return in the case of an empty Series. What do you think? Could just default to:

In [4]: repr(s)
Out[4]: 'Series([], dtype=float64)'

Or it could return a length-0 string

@craustin
Copy link
Author

I'd say since repr returns Series([],... It could make sense to return that. The way we're using to_string, it'd make sense if it returned an empty string (if the newly-added "length" flag is false.

On Dec 14, 2011, at 11:34 PM, Wes McKinneyreply@reply.github.com wrote:

Not obvious what to_string should return in the case of an empty Series. What do you think? Could just default to:

In [4]: repr(s)
Out[4]: 'Series([], dtype=float64)'

Or it could return a length-0 string


Reply to this email directly or view it on GitHub:
https://github.com/wesm/pandas/issues/488#issuecomment-3156677

@wesm
Copy link
Member

wesm commented Dec 15, 2011

Alright, I'm going with empty string (done in the above commit) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants