>>> import pandas as pd
>>> import numpy as np
>>> x1 = {1: 106, 2: 3, 7: 42}
>>> a = x1.keys()
>>> b = x1.values()
>>> df = pd.DataFrame([a,b],index=['type', 'cnt'])#创建dataframe
>>> df2 = pd.DataFrame(df.values.T, index=df.columns, columns=df.index)#转置
>>> print(df)
        0  1   2
type    1  2   7
cnt   106  3  42
>>> print(df2)
   type  cnt
0     1  106
1     2    3
2     7   42
>>>