问题一
pandas数据索引
import pandas as pd
data={'28':1,'29':2,'30':3}
se1=pd.Series(data,name='c')
#创建pandas Series类型
se1
28 1
29 2
30 3
Name: c, dtype: int64
se1.loc['28']# 根据行标签索引
se1.iloc[0]#根据第n行索引
se1[0]#直接索引
#效果相同
data={'28':2,'29':3,'30':4}
se2=pd.Series(data,name='d')
Y=pd.DataFrame([se1,se2])
# 创建DataFrame类型
Y
28 29 30
c 1 2 3
d 2 3 4
Y['28'] # 默认索引只支持列索引(columns)
Y.loc['c']# 行索引标签索引(index)
Y.iloc[0,:]#