相对于NumPy 使用Panda Series的好处

Panda Series 有一些NumPy中没有的功能

主要区别 Pada Series 有索引

import numpy as np
import pandas as pd

a = np.array([1,2,3,4])
s = pd.Series([1,2,3,4])

s.describe()
count    4.000000
mean     2.500000
std      1.290994
min      1.000000
25%      1.750000
50%      2.500000
75%      3.250000
max      4.000000
dtype: float64

life_expectancy = pd.Series([74.7,75.,83.4,57.6]
                            , index = ['Albania','Algeria','Andorra','Angola'])
life_expectancy
Albania    74.7
Algeria    75.0
Andorra    83.4
Angola     57.6
dtype: float64

life_expectancy[0]
74.700000000000003
life_expectancy['Angola']
57.600000000000001

pd.Series([74.7,75.,83.4,57.6])
0    74.7
1    75.0
2    83.4
3    57.6
dtype: float64
life_expectancy.iloc[0]
 
74.700000000000003

# 在这个NumPy数组中,很多人会说'Albania'位置索引是0, 会用中括号调用并获取
# 索引至数组中的数组元素,我一直避免使用这个术语,把它称作位置0 而不是索引0
# 因为在Panada Series中 索引和位置有所不同
countries = np.array(['Albania','Algeria','Andorra','Angola'])
countries[0]
'Albania'










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值