立即学习:https://edu.csdn.net/course/play/26990/361119?utm_source=blogtoedu
pandas.DataFrame创建DataFrame数据结构
pandas.DataFrame(data,index,dtype,columns)
- data可为列表/array/dict
- index:行索引
- columns:列名/列标签
list1=[['张三',23,'男'],['李四',21,'女'],['王五',26,'男']]
df1=pd.DataFrame(list1,columns=['姓名','年龄','性别'])
df1.head(5)
df2=pd.DataFrame({'姓名':['张三','李四','王五'],'年龄':[23,21,26],'性别':['男','女','男']})
df2
array1=np.array([['张三',23,'男'],['李四',21,'女'],['王五',26,'男']])
df3=pd.DataFrame(array1,columns=['姓名','年龄','性别'],index=['a','b','c'])
df3
df3.values
df3.index
df3.conlumns.tolist()#转换成列表
df3.ndim
df3.shape
df3.size
df3.dtype
df2.dtype