
Pandas数据处理入门(一)
5星
- 浏览量: 0
- 大小:None
- 文件类型:PDF
简介:
本教程为《Pandas数据处理》系列的第一部分,主要介绍如何使用Python的Pandas库进行基础的数据操作和分析。适合初学者掌握基本概念与技巧。
Pandas数据处理(一)
导入所需的库:
```python
import pandas as pd
import numpy as np
```
使用numpy生成一组DataFrame数据:
```python
df = pd.DataFrame(np.arange(16).reshape(4, 4))
print(df)
```
输出结果如下所示:
```
0 1 2 3
0 0 1 2 3
1 4 5 6 7
2 8 9 10 11
3 12 13 14 15
```
我们注意到在没有指定行索引的情况下也出现了,这是因为DataFrame是二维数组结构,因此会自动生成行列的索引。当然也可以手动设置索引数值:
```python
df = pd.DataFrame(np.arange(16).reshape(4, 4), index=[row_0, row_1, row_2, row_3])
print(df)
```
这样就可以根据需求来指定DataFrame的行和列标签。
全部评论 (0)
还没有任何评论哟~


