How to see more than five columns of a data frame output in PyCharm run window

已回答

Although I have some experience using R and RStudio for Data Science analysis, I am an absolute beginner with Python and PyCharm. In my work, I need to handle large data frame objects with 50 to 70 columns whose visualisation is very important. PyCharm run window allows for the visualization of just five columns and forces a page break making it difficult to see a larger number of columns side by side. At the same time, it leaves empty most of the right side of the window. I was not not able to work out a way to display columns all over the full width of the run window. I would be grateful if you guys could give me a hint to solve the this problem. Thank you.

2
Avatar
Permanently deleted user

Hi! Instead of printing dataframe to console you can use  "View as DataFrame" feature of PyCharm debugger.

"View as DataFrame" action is available in right-click menu from variables panel in debugger toolwindow if you select any dataframe. If you are not familiar with debugging in PyCharm please check this articles:

1) https://www.jetbrains.com/help/pycharm/2016.2/debugging.html 

2) https://www.jetbrains.com/help/pycharm/2016.2/debug-tool-window-variables.html 

2
Avatar
Permanently deleted user

import pandas as pd

import numpy as np

desired_width=320

pd.set_option('display.width', desired_width)

np.set_printoption(linewidth=desired_width)

pd.set_option('display.max_columns',10)

 

 

I found this info. from below.

https://stackoverflow.com/questions/25628496/getting-wider-output-in-pycharms-built-in-console

11
Avatar
Permanently deleted user

yes Mr Happy2017mj This works good . There is minor typo maybe in the above code.

Here is the corrected one!

np.set_printoptions(linewidth=desired_width)

2

Hi is there some setting in PyCharm to print all data instead of "..."? I copy my python and run in cmd, it prints all data. But in PyCharm run window, it prints five columns and there is "..." in middle of columns. By the way I'm not using pandas or numpy, so I can't set_option() or something.

0

@Bejond

Please provide screenshot and code snippet to better demonstrate what you're talking about. For now I can assume you're executing the code in python console or with debugger, and it does shorten long dataframes.

0

And how to see more then 10 raws?

0

Hello, 

It seems like only in debugging mode. 

Please see: Viewing as array or DataFrame   https://www.jetbrains.com/help/pycharm/viewing-as-array.html#view-as-array 

2

Also, if you use: 

print(poke.to_string())    instead of  print(poke.head(300))   , the whole data frame will be in the output. It is a pandas specific.  

 

 

3

or you can simply put

print(poke.head(300).to_string())

1

请先登录再写评论。