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

API: allow option truncate for display.show_dimensions to only show dimensions if truncated (GH6457) #7108

Merged
merged 1 commit into from
May 14, 2014

Conversation

jreback
Copy link
Contributor

@jreback jreback commented May 13, 2014

closes #6547

add the option 'trunctate'.
Should this be the new default?????

dfd = pd.DataFrame(np.arange(25).reshape(-1,5), index=[0,1,2,3,4], columns=[0,1,2,3,4])

# show dimensions only if truncated
with pd.option_context('display.max_rows', 2, 'display.max_columns', 2,  'display.show_dimensions', 'truncate'):
        print(dfd)
   0  1    
0  0  1 ...
1  5  6 ...
  .. ..    

[5 rows x 5 columns]
# show dimensions only if truncated
with pd.option_context('display.max_rows', 10, 'display.max_columns', 40, 'display.show_dimensions', 'truncate'):
        print(dfd)
    0   1   2   3   4
0   0   1   2   3   4
1   5   6   7   8   9
2  10  11  12  13  14
3  15  16  17  18  19
4  20  21  22  23  24

@jreback jreback added this to the 0.14.0 milestone May 13, 2014
@jreback
Copy link
Contributor Author

jreback commented May 13, 2014

@jreback jreback changed the title API: allow option truncate'or dplay.show_dimensionsto only show dimensions if truncated (GH6457) API: allow option truncateor display.show_dimensions to only show dimensions if truncated (GH6457) May 13, 2014
@jreback jreback changed the title API: allow option truncateor display.show_dimensions to only show dimensions if truncated (GH6457) API: allow option truncate for display.show_dimensions to only show dimensions if truncated (GH6457) May 13, 2014
# show dimensions only if truncated
with pd.option_context('display.max_rows', 2, 'display.max_columns', 2, 'display.width',
500, 'display.expand_frame_repr', 'info', 'display.show_dimensions', 'truncate'):
print dfd
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use print()! Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right! thanks...

@TomAugspurger
Copy link
Contributor

Looks good on a quick glance.


# show dimensions only if truncated
with pd.option_context('display.max_rows', 2, 'display.max_columns', 2, 'display.width',
500, 'display.expand_frame_repr', 'info', 'display.show_dimensions', 'truncate'):
Copy link
Member

Choose a reason for hiding this comment

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

are the display.width and display.expand_frame_repr necessary here in the example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really except that I override these in my environement; so just want to ensure all options are setup to allow expanding (or not)

Copy link
Member

Choose a reason for hiding this comment

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

I see, but for the docs this won't be a problem I think. And now it is a bit overhead for the user to see what the relevant options are. So I would leave them out personally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok...makes sense

@jorisvandenbossche do you think this 'solves' the thread that @jseabold brought up?

@jorisvandenbossche
Copy link
Member

small detail to nitpick, but truncated instead of truncate sounds better to me (as the option), as it is not really involved in the action of truncating, only the state of being truncated

@jreback
Copy link
Contributor Author

jreback commented May 13, 2014

@jorisvandenbossche I agree it sounds better, except, that large_repr uses truncate

and wanted to be consistent, but ok if you feel strongly

@jreback
Copy link
Contributor Author

jreback commented May 13, 2014

changed to use 'truncated' & example in v0.14.0.txt simpler

@jorisvandenbossche
Copy link
Member

Ah, but if large_repr already uses the other, I am not feeling strongly about it.

@jreback about if this closes the issue that @jseabold brought up in #6547, he can maybe better say it himself, but I don't think it really does solve his issue he encountered in statsmodels (the use of dataframes to give back the overview result of a model, for which these dimensions are a bit superfluous/distracting). But as also said on the mailing list, not everybody's needs can be satisfied at the same time.
And this PR provides in any case all needed architecture. Given this, the discussion in the issue/on the mailing list, is only about what should be the default value of display.show_dimensions: True or truncated? True would be compatible with 0.13, truncated would be compatible with <=0.12 (for small dataframes).

@jreback
Copy link
Contributor Author

jreback commented May 13, 2014

ok..put back to 'truncate'.

like @jseabold to comment (and maybe should send to ML). but I think let's make the default 'truncate'.?

@TomAugspurger
Copy link
Contributor

Posted on the ML. I tentatively vote for the default to be truncate(d). That really does fix the statsmodels issue.

@jreback
Copy link
Contributor Author

jreback commented May 13, 2014

thanks @TomAugspurger

jreback added a commit that referenced this pull request May 14, 2014
API: allow option truncate for display.show_dimensions to only show dimensions if truncated (GH6457)
@jreback jreback merged commit 3c57381 into pandas-dev:master May 14, 2014
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.

New DataFrame display information?
3 participants