python之pandas库的series — 整数索引

python之pandas库的series — 整数索引

当series的标签索引也是整数时,怎么区别标签索引和下标索引
loc函数指定索引类型是标签
iloc函数指定索引类型是下标

import pandas as pd 
import numpy as np
a = pd.Series(np.arange(20))
b = a[10:]
c = b.loc[10]
d = b.iloc[9]

print('a=',a)
print('b=',b)
print('c=',c)
print('d=',d)

a= 0      0
1      1
2      2
3      3
4      4
5      5
6      6
7      7
8      8
9      9
10    10
11    11
12    12
13    13
14    14
15    15
16    16
17    17
18    18
19    19
dtype: int32
b= 10    10
11    11
12    12
13    13
14    14
15    15
16    16
17    17
18    18
19    19
dtype: int32
c= 10
d= 19

你可能感兴趣的:(python基础知识,python,pandas,numpy)