1. 程式人生 > >Pandas重塑和軸向旋轉

Pandas重塑和軸向旋轉

import pandas as pd
import numpy as np
from pandas import Series

data=pd.DataFrame(np.arange(6).reshape(2,3),
                  index=['Ohio','Colorado'],
                  columns=['one','two','three']
                 )
data.index.names=['state']
data.columns.names=['number']
data

number     one  two three
   state            
   Ohio     0   1   2
Colorado    3   4   5