Skip to content

ENH: print more detailed truncated sequence if a limit is given #3974

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 0 commits into from
Mar 13, 2014
Merged

ENH: print more detailed truncated sequence if a limit is given #3974

merged 0 commits into from
Mar 13, 2014

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Jun 20, 2013

works similar to numpy except that the edgeitems is overriden by threshold rather than the other way around which is what np does.

closes #3391

  • add release notes

@cpcloud
Copy link
Member Author

cpcloud commented Jun 20, 2013

@y-p can u take a look-see please

@ghost ghost assigned cpcloud Jun 20, 2013
@cpcloud
Copy link
Member Author

cpcloud commented Jun 21, 2013

AH HA! i figured out the case where the overlap happens now i can write a test :) thanks @y-p for pointing that out

@cpcloud
Copy link
Member Author

cpcloud commented Jun 21, 2013

@y-p

numpy's edgeitems (a new option i'm introducing called max_edge_items) overrides threshold (equivalent to our max_seq_items), when threshold < edgeitems.

i don't think numpy's behavior in this regard is necessarily what a user would expect. personally, i would expect max_seq_items to be a "hard limit" on the number of items that repr including the items repr'd on the edge of the sequence, thus i think max_seq_items should override max_edge_items. the edgeitems would then be forced to be at most n / 2 of the sequence, guaranteeing no overlap.

what do you think? this, of course, will not be consistent with numpy. right now the above described behavior is what i'm doing, but i can change if consistency with numpy is preferred.

@cpcloud
Copy link
Member Author

cpcloud commented Jun 21, 2013

here's an example from the tests i've added:

with cf.option_context('display.max_seq_items', 2, 'display.max_edge_items', 5):
    s = 'Int64Index([0, ..., 9], dtype=int64)'
    res = repr(tm.makeIntIndex(10))
    assert_equal(s, res)

@ghost
Copy link

ghost commented Jun 21, 2013

I agree. when I suggested aligning with numpy I meant the format for summary: "foo foo foo ... foo foo foo", i.e.
symmetric. what you propose sounds right to me.

As simple as possible but no simpler.

@cpcloud
Copy link
Member Author

cpcloud commented Jun 21, 2013

for the special case of repring a MultiIndex when max_seq_items == 1 i think the repr should be

MultiIndex
[(u'C_l0_g0', ...), ...]

@ghost
Copy link

ghost commented Jun 21, 2013

Put constraints on the setting of of max_seq_items (even number >=2), and save yourself the special cases.
Yes, for MultiIndex, considering each tuple as an item makes sense.

@cpcloud
Copy link
Member Author

cpcloud commented Jun 21, 2013

that certainly simplifies my life a lot

raise ValueError("value must be a positive integer")


def is_pos_int_or_none(value):
Copy link
Member Author

Choose a reason for hiding this comment

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

note to self remove this

@cpcloud
Copy link
Member Author

cpcloud commented Jun 22, 2013

@y-p can u take a look when u get a chance? thanks

@jreback
Copy link
Contributor

jreback commented Sep 30, 2013

@cpcloud close/push to 0.14?

@jreback
Copy link
Contributor

jreback commented Oct 11, 2013

@cpcloud ?

1 similar comment
@jreback
Copy link
Contributor

jreback commented Oct 16, 2013

@cpcloud ?

@cpcloud
Copy link
Member Author

cpcloud commented Oct 16, 2013

pushing to 0.14

@jreback jreback closed this Jan 3, 2014
@ghost ghost reopened this Jan 3, 2014
@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

@y-p must have been accident

@ghost
Copy link

ghost commented Jan 3, 2014

It's stale, but it needs to happen for 0.14. If @cpcloud doesn't finish, I'll do it.

@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

@y-p gr8...i think i got all the accid closed ones...weird

@jreback
Copy link
Contributor

jreback commented Mar 9, 2014

@cpcloud what's the state of this?

@cpcloud
Copy link
Member Author

cpcloud commented Mar 12, 2014

I'll try to get this cleaned up this weekend.

@cpcloud
Copy link
Member Author

cpcloud commented Mar 12, 2014

Something happened just now when I tried to update the remote .... getting the infinity commits again.

@cpcloud
Copy link
Member Author

cpcloud commented Mar 12, 2014

Oh fudge I had those in a stash that has since been deleted .... ah well ... nothing major anyway. I'll open another PR.

@jreback jreback merged commit 98f51f5 into pandas-dev:master Mar 13, 2014
@cpcloud cpcloud deleted the large-sequence-printing branch April 19, 2014 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assign a default value for display max_seq_items
2 participants