Skip to content

BUG: empty series not printing name in repr (#4651) #5335

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
Nov 2, 2013
Merged

BUG: empty series not printing name in repr (#4651) #5335

merged 1 commit into from
Nov 2, 2013

Conversation

goyodiaz
Copy link
Contributor

Implemented as suggested in #4651

@jreback
Copy link
Contributor

jreback commented Oct 28, 2013

@jtratner this ok I think? (I can rebase on merge)

@jtratner
Copy link
Contributor

needs to check if it has a name, no?

something like:

attrs = ", ".join("%s: %s" % (attr, val) for attr, val in [('dtype', self.dtype), ('name', self.name)] if val is not None)
return "Series([], %s)" % attrs

Also, that will eventually make it easier to handle metadata if we want (I guess)

@jreback
Copy link
Contributor

jreback commented Oct 28, 2013

well, these are always defined on series, so I think its ok (name could be None of course)

@jtratner
Copy link
Contributor

Right, but it doesn't show it in normal Series repr if None:

In [2]: ser = pd.Series([1, 2])

In [3]: ser
Out[3]:
0    1
1    2
dtype: int64

In [4]: ser.name = "apple"

In [5]: ser
Out[5]:
0    1
1    2
Name: apple, dtype: int64

@jtratner
Copy link
Contributor

so empty series repr would be:

ser = pd.Series([], dtype=object)
ser
Series([], dtype=object)
ser.name = "apple"
Series([], name="apple", dtype=object)

should fix the ordering that I posted there though.

Also, I prefer to put dtype in quotes so you can always copy paste, so that would be a good addition (don't do %r, just '%s')

@jreback
Copy link
Contributor

jreback commented Oct 30, 2013

@jtratner this look ok to me.....I understand you want dtype in quotes, but that is a big change (as its not done elsewhere)

@jtratner
Copy link
Contributor

Not a big deal to me either way - and generally you're not copy/pasting
Series/Frame reprs anyways.

@jreback
Copy link
Contributor

jreback commented Oct 30, 2013

@goyodiaz can you rebase ?

@jreback
Copy link
Contributor

jreback commented Oct 31, 2013

I think we omit name if it is None, can you make this change?

In [1]: Series(name='foo')
Out[1]: Series([], name: foo, dtype: float64)

In [2]: Series()
Out[2]: Series([], name: None, dtype: float64)

In [3]: Series(dtype=object)
Out[3]: Series([], name: None, dtype: object)

In [4]: Series(dtype=object,name='foo')
Out[4]: Series([], name: foo, dtype: object)

In [5]: Series([1,2])
Out[5]: 
0    1
1    2
dtype: int64

@goyodiaz
Copy link
Contributor Author

I will try to look at this tomorrow.

jreback added a commit that referenced this pull request Nov 2, 2013
BUG: empty series not printing name in repr (#4651)
@jreback jreback merged commit 48156af into pandas-dev:master Nov 2, 2013
@jreback
Copy link
Contributor

jreback commented Nov 2, 2013

thanks!

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

Successfully merging this pull request may close these issues.

3 participants