如何在 Jupyter Notebook 的 Markdown 单元格左侧显示 table
How to display table on left side of Markdown cell Jupyter Notebook
在 2 个代码单元格之间的 Markdown 单元格中有一个 table,它是自动居中的,我想像文本一样位于单元格的左侧。
代码如下:
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).
您可以使用 Markdown
和 display
来达到这样的效果。以下是步骤:
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).
''')
要显示,请执行此操作
display(m0,m1,m2)
在 2 个代码单元格之间的 Markdown 单元格中有一个 table,它是自动居中的,我想像文本一样位于单元格的左侧。
代码如下:
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).
您可以使用 Markdown
和 display
来达到这样的效果。以下是步骤:
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).
''')
要显示,请执行此操作
display(m0,m1,m2)