Skip to content

安装与配置

安装 Pandas

使用 pip 安装

bash
pip install pandas

使用 conda 安装

bash
conda install pandas

安装指定版本

bash
pip install pandas==2.0.0

验证安装

python
import pandas as pd

print(pd.__version__)

安装推荐依赖

为了获得更好的体验,建议同时安装以下库:

bash
pip install numpy matplotlib openpyxl xlrd

开发环境配置

Jupyter Notebook

bash
pip install jupyter
jupyter notebook

VS Code

安装 Python 扩展,配置 Python 解释器。

第一个 Pandas 程序

python
import pandas as pd

# 创建一个简单的数据框
data = {
    '姓名': ['张三', '李四', '王五'],
    '年龄': [25, 30, 35],
    '城市': ['北京', '上海', '广州']
}

df = pd.DataFrame(data)
print(df)

输出:

   姓名  年龄  城市
0  张三   25  北京
1  李四   30  上海
2  王五   35  广州

恭喜!你已经成功运行了第一个 Pandas 程序。