DataFrames中的reindex用法

from pandas import DataFramepandas

frame = DataFrame(np.arange(9).reshape((3,3)),index=['a','c','d'],columns=['Ohio','Texas','California']io

states = ['Texas','Utah','California']import

 

frame.reindex(columns=states)im

# a index賦值給bco

frame.reindex(index=['a','b','c','d',method='ffill',columns=states)index

# c index賦值給b

frame.reindex(index=['a','b','c','d',method='ffill',columns=states)

相關文章
相關標籤/搜索