コンテンツにスキップ
Hextra v0.12 がリリースされました!🎉 新着情報はこちら

Jupyter Notebook コンポーネント

Jupyter Notebook をショートコード経由で組み込む実験的機能です。すべてのセルタイプがサポートされているわけではありません。

Jupyter NotebookProject Jupyter の言語非依存な HTML ノートブックアプリケーションです。ライブコード、数式、可視化、説明文を含むドキュメントを作成・共有できます。

使用方法

ローカルノートブックの使用

Jupyter Notebook ショートコードを使用するには、プロジェクト内に Jupyter Notebook ファイルが必要です。画像を追加する方法と同様に、Jupyter Notebook を assets フォルダに追加できます。

    • notebook.ipynb
      • my-page.md

jupyter ショートコードを使用してページに Jupyter Notebook を組み込みます:

content/docs/my-page.md
---
title: マイページ
math: true
---

{{% jupyter "notebook.ipynb" %}}

あるいは、Hugo の ページバンドル 機能を利用して、Jupyter Notebook を Markdown ファイルと一緒に整理することもできます。

        • index.md
        • notebook.ipynb
content/docs/my-page/index.md
---
title: マイページ
math: true
---

{{% jupyter "notebook.ipynb" %}}

リモートノートブックの使用

ノートブックファイルの URL を指定することで、リモートノートブックも使用できます。例えば、What is the Jupyter Notebook ノートブックをページに組み込むには、以下のショートコードを使用します:

{{% jupyter "https://raw.githubusercontent.com/jupyter/notebook/main/docs/source/examples/Notebook/What%20is%20the%20Jupyter%20Notebook.ipynb" %}}

ノートブックの例

以下は、プロジェクトの assets フォルダに含まれるノートブックファイルの例です。

What is the Jupyter Notebook?

The Jupyter Notebook is an interactive computing environment that enables users to author notebook documents that include:

  • Live code
  • Interactive widgets
  • Plots
  • Narrative text
  • Equations
  • Images
  • Video

These documents provide a complete and self-contained record of a computation that can be converted to various formats and shared with others using email, version control systems (like Git/GitHub) or nbviewer.jupyter.org.

Data Visualization

Below is an example of a simple data visualization using the Seaborn library.

# Import seaborn
import seaborn as sns

# Apply the default theme
sns.set_theme()

# Load an example dataset
tips = sns.load_dataset("tips")

# Create a visualization
sns.relplot(
    data=tips,
    x="total_bill", y="tip", col="time",
    hue="smoker", style="smoker", size="size",
)
Matplotlib is building the font cache; this may take a moment.
<seaborn.axisgrid.FacetGrid at 0x12830caa0>
image
tips.head()
   total_bill   tip     sex smoker  day    time  size
0       16.99  1.01  Female     No  Sun  Dinner     2
1       10.34  1.66    Male     No  Sun  Dinner     3
2       21.01  3.50    Male     No  Sun  Dinner     3
3       23.68  3.31    Male     No  Sun  Dinner     2
4       24.59  3.61  Female     No  Sun  Dinner     4

total_billtipsexsmokerdaytimesize
016.991.01FemaleNoSunDinner2
110.341.66MaleNoSunDinner3
221.013.50MaleNoSunDinner3
323.683.31MaleNoSunDinner2
424.593.61FemaleNoSunDinner4

Equations

The following is an example of a simple equation using LaTeX.

E=mc2 E = mc^2
最終更新日