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

feature request: displaying lots of columns #2076

Closed
vgoklani opened this issue Oct 16, 2012 · 8 comments
Closed

feature request: displaying lots of columns #2076

vgoklani opened this issue Oct 16, 2012 · 8 comments
Labels
Enhancement Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@vgoklani
Copy link

Hi,

What's the plan for displaying head() cleanly on my dataframe when there are lots of columns?

R handle's this easily by wrapping the output across multiple lines.

Thanks,

Vishal

@lodagro
Copy link
Contributor

lodagro commented Oct 16, 2012

You have two options;

  • print df.to_string()
  • disable the terminal size detection and the automatic switch over between full and info view e.g. pd.set_printoptions(max_columns=50).

see also:

In [41]: df = pd.DataFrame(np.random.randn(2, 20))

In [42]: df
Out[42]: 
<class 'pandas.core.frame.DataFrame'>
Int64Index: 2 entries, 0 to 1
Data columns:
0     2  non-null values
1     2  non-null values
2     2  non-null values
3     2  non-null values
4     2  non-null values
5     2  non-null values
6     2  non-null values
7     2  non-null values
8     2  non-null values
9     2  non-null values
10    2  non-null values
11    2  non-null values
12    2  non-null values
13    2  non-null values
14    2  non-null values
15    2  non-null values
16    2  non-null values
17    2  non-null values
18    2  non-null values
19    2  non-null values
dtypes: float64(20)

In [43]: print df.to_string()
         0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16        17        18        19
0 -1.120988 -0.014668  1.005053 -1.171275  0.819571  1.376871  0.192588  0.052807 -0.847959 -1.220135  1.367997 -1.302833  1.717463 -0.306201 -0.037465 -0.067757 -1.137955 -0.508188 -0.385194  1.289037
1 -0.348980 -0.538781  0.903626 -1.481493 -1.191302 -0.509413 -0.863830 -2.581788 -0.965519  0.152339  0.039064 -0.339086 -0.114939 -1.277665  0.537978 -1.072551 -0.772296 -0.719904  0.819310 -0.422032

In [44]: pd.set_printoptions(max_columns=50)

In [45]: df
Out[45]: 
         0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16        17        18        19
0 -1.120988 -0.014668  1.005053 -1.171275  0.819571  1.376871  0.192588  0.052807 -0.847959 -1.220135  1.367997 -1.302833  1.717463 -0.306201 -0.037465 -0.067757 -1.137955 -0.508188 -0.385194  1.289037
1 -0.348980 -0.538781  0.903626 -1.481493 -1.191302 -0.509413 -0.863830 -2.581788 -0.965519  0.152339  0.039064 -0.339086 -0.114939 -1.277665  0.537978 -1.072551 -0.772296 -0.719904  0.819310 -0.422032

@wesm
Copy link
Member

wesm commented Oct 20, 2012

I'd be willing to basically "take the R approach" of wrapping columns. Have to take a look

@vgoklani
Copy link
Author

I've been using the approach mentioned above, but obviously R's implementation is much easier to read for high-dimensional datasets.

Thanks!
On Oct 20, 2012, at 2:32 PM, Wes McKinney notifications@github.com wrote:

I'd be willing to basically "take the R approach" of wrapping columns. Have to take a look


Reply to this email directly or view it on GitHub.

@ghost
Copy link

ghost commented Dec 11, 2012

@changhiskhan , wide repr closed this?

@changhiskhan
Copy link
Contributor

Yup go ahead and close
On Dec 11, 2012 12:30 AM, "y-p" notifications@github.com wrote:

@changhiskhan https://github.com/changhiskhan , wide repr closed this?


Reply to this email directly or view it on GitHubhttps://github.com//issues/2076#issuecomment-11231780.

@vgoklani
Copy link
Author

I saw the ipython notebook on twitter, the update is pretty slick! Just two quick questions:

  1. what's the distinction between set_option and set_printoptions? why do you have two different setters?
  2. is there a way to auto-set the line_width to match the current window size of the terminal?

Thanks!

Vishal

@ghost
Copy link

ghost commented Dec 11, 2012

  1. for back-compatibility. If you use set_printoption now, there's a deprecation warning.
  2. Currently not, it's a little sticky because terminal width is not available in IPython frontends.
    maybe in the future.

@ghost ghost closed this as completed Dec 11, 2012
@wesm
Copy link
Member

wesm commented Dec 12, 2012

Probably possible to add an option at some point for #2 (would be nice for interactive stuff)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

4 participants