Printing 2 Python Pandas DataFrame in HTML Tables in iPython Notebook

Nyxynyx

Question: How can you print 2 DataFrame tables together from 1 iPython Notebook row, such that both tables are displayed in the pretty table format?

The following prints just the second one, and print df.head() does not produce a pretty table.

df = pd.DataFrame(np.random.randn(6,4), index=pd.date_range('20150101', periods=6), columns=list('ABCD'))
df2 = pd.DataFrame(np.random.randn(6,4), index=pd.date_range('20150101', periods=6), columns=list('WXYZ'))


df.head()
df2.head()

enter image description here

The following does not produce the pretty table needed:

print df.head()
print df2.head()
joris

In the IPython notebook, only the result of the last line of a cell is shown, unless it is explicitly printed or displayed.

Some options:

  • Put the second df.head() in the next cell
  • Use print df to explicitly print the dataframe -> but, this gives the text representation instead of html representation
  • Use display(df) to explicitly display the dataframe, this will give the same html representation as how a dataframe is shown by default. You need the following import for this:

    from IPython.display import display
    

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

iPython Notebook not printing Dataframe as table

From Dev

How to *not* display 'NaN' in ipython notebook (html table of pandas dataframe)?

From Dev

Display multiple output tables in IPython notebook using Pandas

From Dev

Python dictionary as html table in ipython notebook

From Dev

Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

From Dev

IPython Notebook & Pandas: How does pandas produce html table?

From Dev

Error when using pandas dataframe map function in ipython notebook

From Dev

resize ipython notebook output window with pandas dataframe output

From Dev

resize ipython notebook output window with pandas dataframe output

From Dev

IPython Notebook and Pandas autocomplete

From Dev

How to format IPython html display of Pandas dataframe?

From Dev

Ipython notebook on 2 columns

From Dev

ipython notebook is NOT printing until the whole program is finished

From Java

Show DataFrame as table in iPython Notebook

From Dev

Jupyter (IPython) notebook: Convert an HTML notebook to ipynb

From Dev

Import html to ipython notebook file

From Dev

plotting in ipython notebook in 2 steps

From Dev

How can I left justify text in a pandas DataFrame column in an IPython notebook

From Dev

Pandas DataFrame joining 2 tables on <,> conditions

From Dev

Rendering a pandas dataframe as HTML with same styling as Jupyter Notebook

From Dev

Show all pandas dataframes in an IPython Notebook

From Dev

ipython notebook pandas max allowable columns

From Dev

pandas subplot title size in ipython notebook

From Dev

Charting gender in IPython notebook using pandas or matplotlib

From Dev

Converting ipython notebook to html with separate images

From Dev

CSS Styling of HTML in IPython Notebook output

From Dev

Displaying an HTML file with a JS inside an iPython notebook

From Dev

Python pandas : Merge two tables without keys (Multiply 2 dataframes with broadcasting all elements; NxN dataframe)

From Java

Using both Python 2.x and Python 3.x in IPython Notebook

Related Related

  1. 1

    iPython Notebook not printing Dataframe as table

  2. 2

    How to *not* display 'NaN' in ipython notebook (html table of pandas dataframe)?

  3. 3

    Display multiple output tables in IPython notebook using Pandas

  4. 4

    Python dictionary as html table in ipython notebook

  5. 5

    Anaconda: Python 3 and 2 in IPython/Jupyter Notebook

  6. 6

    IPython Notebook & Pandas: How does pandas produce html table?

  7. 7

    Error when using pandas dataframe map function in ipython notebook

  8. 8

    resize ipython notebook output window with pandas dataframe output

  9. 9

    resize ipython notebook output window with pandas dataframe output

  10. 10

    IPython Notebook and Pandas autocomplete

  11. 11

    How to format IPython html display of Pandas dataframe?

  12. 12

    Ipython notebook on 2 columns

  13. 13

    ipython notebook is NOT printing until the whole program is finished

  14. 14

    Show DataFrame as table in iPython Notebook

  15. 15

    Jupyter (IPython) notebook: Convert an HTML notebook to ipynb

  16. 16

    Import html to ipython notebook file

  17. 17

    plotting in ipython notebook in 2 steps

  18. 18

    How can I left justify text in a pandas DataFrame column in an IPython notebook

  19. 19

    Pandas DataFrame joining 2 tables on <,> conditions

  20. 20

    Rendering a pandas dataframe as HTML with same styling as Jupyter Notebook

  21. 21

    Show all pandas dataframes in an IPython Notebook

  22. 22

    ipython notebook pandas max allowable columns

  23. 23

    pandas subplot title size in ipython notebook

  24. 24

    Charting gender in IPython notebook using pandas or matplotlib

  25. 25

    Converting ipython notebook to html with separate images

  26. 26

    CSS Styling of HTML in IPython Notebook output

  27. 27

    Displaying an HTML file with a JS inside an iPython notebook

  28. 28

    Python pandas : Merge two tables without keys (Multiply 2 dataframes with broadcasting all elements; NxN dataframe)

  29. 29

    Using both Python 2.x and Python 3.x in IPython Notebook

HotTag

Archive