pandas入门基础-Series和DataFrame.reindex
演示:jupyter
Series的索引
1 Series的索引index
先建立一个Series对象
in:
import pandas as pd
import numpy as np
s = pd.Series([1,2,3,6,7],index=list('acefh'))
s
out:
a 1
c 2
e 3
f 6
h 7
dtype: int64
in:Series的索引
s.index
out:类型未对象类型
Index(['a', 'c', 'e', 'f', 'h'], dtype='object')
2 Series的重新索引reindex
reindex,它的作用是创建一个新对象,新对象的数据符合新的索引。
Series.reindex(self, labels=None, index=None, columns=None, axis