jupyter notebook简单案例
时间: 2023-04-27 07:03:34 浏览: 237
Jupyter Notebook是一个交互式的笔记本,可以用于数据分析、可视化和编程等多种用途。以下是一个简单的Jupyter Notebook案例:
1. 打开Jupyter Notebook,创建一个新的Notebook。
2. 在第一个单元格中输入以下代码:
```python
print("Hello, World!")
```
3. 点击运行按钮或按下Shift + Enter键,输出结果为:
```
Hello, World!
```
4. 在第二个单元格中输入以下代码:
```python
import pandas as pd
data = {'Name': ['John', 'Mary', 'Peter', 'Jane'], 'Age': [25, 30, 35, 40]}
df = pd.DataFrame(data)
df.head()
```
5. 点击运行按钮或按下Shift + Enter键,输出结果为:
```
Name Age
John 25
1 Mary 30
2 Peter 35
3 Jane 40
```
6. 在第三个单元格中输入以下代码:
```python
import matplotlib.pyplot as plt
plt.bar(df['Name'], df['Age'])
plt.show()
```
7. 点击运行按钮或按下Shift + Enter键,输出结果为一个柱状图,显示每个人的年龄:

这是一个简单的Jupyter Notebook案例,展示了如何使用Jupyter Notebook进行编程、数据分析和可视化。
阅读全文
相关推荐
















