gumdropsteve
gumdropsteve

Reputation: 70

How to display table on left side of Markdown cell Jupyter Notebook

Have a table in a Markdown cell between 2 code cells, it is auto centering and I would like to to be on the left side of the cell like the text.

table is aligning in center of cell, want it to be on the left

Here's the code:

Let's use the first row of `indices` to classify the 0th flower in `X_test`.

species    | target
---        | ---
setosa     | 0
versicolor | 1
virginica  | 2

This cell prints the neighbor's position of closeness, index of the neighbor and that neighbor's `target` (Iris species).

Upvotes: 0

Views: 1839

Answers (1)

swatchai
swatchai

Reputation: 18782

You can use Markdown and display to achieve such results. Here is the steps:

from IPython.core.display import Markdown
m0 = Markdown('''
Let's use the first row of `indices` to classify the 0th flower in `X_test`.
''')
m1 = Markdown('''
|species    | target | 
|-----------|:------:|
|setosa     | 0      |
|versicolor | 1      |
|virginica  | 2      |
''')
m2 = Markdown('''
This cell prints the neighbor's position of closeness, index of the neighbor and that neighbor's `target` (Iris species).
''')

To display, do this

display(m0,m1,m2)

Upvotes: 3

Related Questions