import numpy as np import pandas as pd data=pd.DataFrame(np.arange(4).reshape((2,2)), index=pd.Index(['row1','row2'],name='rows'), columns=pd.Index(['one','two'],name='cols')) print(data)
时间: 2023-12-02 17:04:12 浏览: 33
这段代码的作用是生成一个2行2列的DataFrame对象,其中数据为0到3的数字序列,行索引为'row1'和'row2',列索引为'one'和'two',并打印输出该DataFrame对象。输出结果如下:
```
cols one two
rows
row1 0 1
row2 2 3
```