pandas对象有一个重要的方法reindex,作用:创建一个适应新索引的新对象
以Series为例
1 >>> series_obj = Series([4.5,1.3,5,-5.5],index=('a','b','c','d')) 2 >>> series_obj 3 a 4.5 4 b 1.3 5 c 5.0 6 d -5.5 7 dtype: float64 8 >>> obj2 = series_obj.reindex(['a','b','c','e','f']) 9 >>> obj2 10 a 4.5 11 b 1.3 12 c 5.0 13 e NaN 14 f NaN 15 dtype: float64