![]() |
Pandas dataframe columns collapsed in Spyder when printing - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Pandas dataframe columns collapsed in Spyder when printing (/thread-22176.html) |
Pandas dataframe columns collapsed in Spyder when printing - UniKlixX - Nov-02-2019 Hello everyone! I have this tiny problem when using Pandas inside the Spyder IDE. BTW I am still kind of new to Python and libraries so I hope you can forgive me for my beginner question. So, what I want is to print a preview of a query I made with Google BigQuery (health data). For this, I used print(df.head(5))in my script. However, what I get in the console view is a "collapsed" view of the data frame with columns replaced by dots in the console, like this: Per stat: provider_city ... average_medicare_payments 0 ABINGTON ... 3992.93 1 AKRON ... 4292.47 2 ALBANY ... 3834.18 3 ALBANY ... 5137.31 4 ALLENTOWN ... 3913.78Note the dots replacing the columns. I have seen other examples of this, and in that case the columns were shown in the preview. So is there a way to enable a wider view of the data frame? I have searched on the internet but all the solutions I tried didn't work as intended ![]() What I did in my case was to use tkinter to print the entire sheet instead and look at the data. But since this is kind of irritating doing all the time when working with my data, I would love to hear your opinion on this matter. Thanks very much in advance! RE: Pandas dataframe columns collapsed in Spyder when printing - jefsummers - Nov-02-2019 This may or may not work for you. pd.set_option("display.max_columns",200)it will display up to 200 columns. However, it will do so by displaying them in groups, stacked on each other. RE: Pandas dataframe columns collapsed in Spyder when printing - UniKlixX - Nov-04-2019 (Nov-02-2019, 06:33 PM)jefsummers Wrote: This may or may not work for you.pd.set_option("display.max_columns",200)it will display up to 200 columns. However, it will do so by displaying them in groups, stacked on each other. Thank you so much, this did the trick! This method surely will be most useful for me in my tasks ![]() Thank you for your assistance ![]() EDIT: I noticed that in some cases this method doesn't quite work as intended (like you implied) ![]() ![]() For this project, I guess I will just stick with tkinter and view the full sheet ![]() |