This is an example Jupyter notebook that includes Quarto front matter. The front matter is included in a raw cell at the beginning of the notebook.
Code
import pandas as pdimport matplotlib.pyplot as plt
Hide code but show output:
#| echo: false
Show code but hide output:
#| output: false
Code
import numpy as nprandom_numbers = np.random.rand(5)print(random_numbers)
Hide both code and output:
#| include: false
Show code with line numbers:
#| echo: true
#| code-line-numbers: true
Code
def fibonacci(n):if n <=1:return nelse:return fibonacci(n-1) + fibonacci(n-2)print(fibonacci(10))
55
Fold code (collapsible):
#| code-fold: true
Code
import seaborn as snsimport matplotlib.pyplot as plttips = sns.load_dataset("tips")sns.scatterplot(data=tips, x="total_bill", y="tip")plt.show()
Include warnings in output:
#| warning: true
Code
import warningswarnings.warn("This is a warning message")
/var/folders/pf/662q3gzd6413np78gpd4p9hr0000gn/T/ipykernel_61213/1498169789.py:2: UserWarning: This is a warning message
warnings.warn("This is a warning message")
# Create a simple plotplt.figure(figsize=(10, 6))plt.plot(df['x'], df['y'], marker='o')plt.title('Sample Plot')plt.xlabel('X-axis')plt.ylabel('Y-axis')plt.grid(True)plt.show()
Code
df
x
y
0
1
1
1
2
4
2
3
9
3
4
16
4
5
25
5
6
36
6
7
49
7
8
64
8
9
81
9
10
100
Conclusion
This example demonstrates how to include Quarto front matter in a Jupyter notebook. When rendered with Quarto, this notebook will use the specified format options.