首页 > 其他 > 详细

Pandas

时间:2020-07-11 22:37:54      阅读:65      评论:0      收藏:0      [点我收藏+]

Pandas是python的一个数据分析包,包含以下几种数据结构:

1. Series:类似于一维数组,包含索引和值两个部分

2. DataFrame: 类似于二维数组,用于存放二维表格型数据结构,包含行索引、列索引和值三个部分

Series

1 Series的创建:

默认索引:S1 = pd.Series([‘Sam‘, 15, ‘France‘, ‘male‘])   

指定索引:S1 = pd.Series([‘Sam‘, 15, ‘France‘, ‘male‘], index=[‘name‘,‘age‘,‘country‘,‘gender‘])   

字典创建:S1 = pd.Series({‘name‘:‘Sam‘, ‘age‘:15, ‘country‘:‘France‘, ‘gender‘:‘male‘})   

字典+索引:S1 = pd.Series({‘name‘:‘Sam‘, ‘age‘:15, ‘country‘:‘France‘, ‘gender‘:‘male‘}, index=[‘name‘, ‘gender‘, ‘age‘, ‘country‘])       

2 访问Series的值

通过索引名:S1[‘name‘]

通过序号:S1[0]

3 Series的属性

Series的值:S1.values

Series的索引:S1.index

Series的形状:S1.shape

Pandas

原文:https://www.cnblogs.com/bill-h/p/13285193.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!