# Problem displaying dataframe in Jupyterlab notebook using python

**URL:** <https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462>\
**Category:** JupyterLab\
**Tags:** help-wanted\
**Created:** [January 5, 2022, 4:57pm UTC](https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462 "2022-01-05T16:57:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Murphy](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sean_murphy/32/5948_2.png) [@Sean\_Murphy](https://discourse.jupyter.org/u/Sean_Murphy)\
**Post date:** [January 5, 2022, 4:57pm UTC](https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462/1 "2022-01-05T16:57:20Z")

</div>

Hi,

I’m trying to get a notebook running in a jupyterlab instance to display a dataframe.

According to some stackoverflow posts, I should be able to simply import IPython.display and  
use this as display. However, this does not seem to do anything specific and in particular, it does  
not display the dataframe in tabular format.

Any tips on how to output the contents of the dataframe as a table within jupyterlab?

I’m using the jupyterlab/pyspark-notebook container from a couple of days ago on our k8s cluster.

Thanks in advance for any pointers,  
Sean.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [January 5, 2022, 6:53pm UTC](https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462/2 "2022-01-05T18:53:24Z")

</div>

You can just use `display(...)` in JupyterLab, you shouldn’t need to import anything.

For example: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gist/manics/3f31d33306ba21e8d908e02e13d26489/HEAD?labpath=example.ipynb)

---

<div class="post-metadata">

**Author:** ![Sean\_Murphy](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sean_murphy/32/5948_2.png) [@Sean\_Murphy](https://discourse.jupyter.org/u/Sean_Murphy)\
**Post date:** [January 6, 2022, 9:27am UTC](https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462/3 "2022-01-06T09:27:32Z")

</div>

Thanks for the quick response - I tried the sample you provided in a notebook on our system and everything works as you indicate.

It seems to be an issue with using spark and the Dataframe that is returned from  
a sqlContext.createDataFrame() call - when I used display on such a dataframe, I get a  
summary of the types in the dataframe, rather than the contents of the dataframe itself.

For example:

df1 = sqlContext.createDataFrame(departmentsWithEmployeesSeq1)  
display(df)

returns

DataFrame[department: structid:string,name:string, employees: array\<structfirstName:string,lastName:string,email:string,salary:bigint\>]

(for a simple example, I’m working with…)

Any idea how to deal with this?

Thanks, rgds,  
Sean.

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [January 6, 2022, 4:30pm UTC](https://discourse.jupyter.org/t/problem-displaying-dataframe-in-jupyterlab-notebook-using-python/12462/4 "2022-01-06T16:30:23Z")

</div>

It seems you working with Spark dataframe which is a different beast than the more common Pandas dataframe? (See [here](https://www.kdnuggets.com/2016/01/python-data-science-pandas-spark-dataframe-differences.html) although that may be outdated now as I expect development has continued.)  
I had come across some information about displaying them a while back when trying to help someone with an issue. Maybe the resources I pointed to in the top of [my post here](https://discourse.jupyter.org/t/object-reference-output-instead-of-html/2639/9) could be useful for you?
