字典对象data定义如下:data{’name’:['zs','ls','ww','zl','lq'],'age':[23,24,22,25,21],'ht':[1.6,1.7,1.65,1.82,1.72]}使用字典对象data创建DataFrame对象member,行索引值为['101','102','103','104','105'].要求:显示member并使用columns、index和values属性查看member的列索引名、行索引名和值
时间: 2023-09-17 22:14:28 浏览: 415
可以使用pandas库中的DataFrame()方法将字典对象转换成DataFrame对象,并指定行索引值为['101','102','103','104','105'],代码如下:
```python
import pandas as pd
data = {'name':['zs','ls','ww','zl','lq'],'age':[23,24,22,25,21],'ht':[1.6,1.7,1.65,1.82,1.72]}
member = pd.DataFrame(data, index=['101','102','103','104','105'])
print(member)
print('列索引名:', member.columns)
print('行索引名:', member.index)
print('值:', member.values)
```
输出结果如下:
```
name age ht
101 zs 23 1.60
102 ls 24 1.70
103 ww 22 1.65
104 zl 25 1.82
105 lq 21 1.72
列索引名: Index(['name', 'age', 'ht'], dtype='object')
行索引名: Index(['101', '102', '103', '104', '105'], dtype='object')
值: [['zs' 23 1.6]
['ls' 24 1.7]
['ww' 22 1.65]
['zl' 25 1.82]
['lq' 21 1.72]]
```
阅读全文
相关推荐

















