Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm not displaying wide Dataframe in Jupyter Notebook

In Pycharm, I'm using a Jupyter notebook, but when the pandas dataframe I'm working with gets wider than the width of the cell it doesn't display the dataframe anymore. Instead there's just a horizontal line across the output cell. I've tried setting the max columns, width, and every other pandas display option and it's still happening. The dataframe displays fine if I widen the Pycharm window, but for dataframes wider than my screen that's not possible.

Here's a screengrab of what it looks like

import pandas as pd
import numpy as np

display(HTML("<style>.container { width:95% !important; }</style>"))
pd.options.display.max_rows = 50
pd.options.display.max_columns = 200
desired_width = 320    
pd.set_option('display.width', desired_width)
pd.set_option('display.height', 1000)
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
pd.set_option('display.expand_frame_repr', False)
pd.set_option('display.max_columns', None)


dates = pd.date_range('20130101',periods=6)
dates
df = pd.DataFrame(np.random.randn(6,19),index=dates,columns=list('ABCDEFGHIJKLMNOPQRS'))
#df
df = pd.DataFrame(np.random.randn(6,11),index=dates,columns=list('ABCDEFGHIJK'))
df
#df = pd.DataFrame(np.random.randn(6,8),index=dates,columns=list('ABCDEFGH'))
like image 834
user7340 Avatar asked Aug 24 '17 16:08

user7340


People also ask

How do you display a DataFrame in Jupyter Notebook?

You can visualize a pandas dataframe in Jupyter notebooks by using the display(<dataframe-name>) function. The display() function is supported only on PySpark kernels. The Qviz framework supports 1000 rows and 100 columns.

How do I visualize a DataFrame in PyCharm?

In the Variables tab of the Debug tool window, select an array or a DataFrame. Click a link View as Array/View as DataFrame to the right. Alternatively, you can choose View as Array or View as DataFrame from the context menu.

How do I get Jupyter Notebook to show all columns of DataFrame?

To show all columns in Pandas we can set the option: pd. option_context – display. max_columns to None. This will show all columns in the current DataFrame.

How do you display DataFrame next to plot in Jupyter Notebook?

Create a new figure or activate an existing figure using figure() method. Add a subplot to the figure with nrows=1, cols=2 and index=1. Plot dataframe points using scatter() method. Add subplot to the figure with nrows=1, cols=2 and index=2.


1 Answers

This is a PyCharm bug and it still has not been resolved in the latest (2017.3) version.

Only 1D dataframes are shown as expected, multidimensional dataframes are shown as a horizontal line.

You can vote this issue in IntelliJ's issue tracker: https://youtrack.jetbrains.com/issue/PY-25931

like image 135
Furkan Tektas Avatar answered Oct 04 '22 09:10

Furkan Tektas