展开全部
一创建DataFrame的简单操作:
1.根据字典创造:
In [1]: import pandas as pd
In [3]: aa={'one':[1,2,3],'two':[2,3,4],'three':[3,4,5]}
In [4]: bb=pd.DataFrame(aa)
In [5]: bb
Out[5]:
one three two
0 1 3 2
1 2 4 3
2 3 5 4`123456789123456789
字典中的keys就是DataFrame里面的columns,但是没有index的值e5a48de588b662616964757a686964616f31333361316639,所以需要自己设定,不设定默认是从零开始计数。
bb=pd.DataFrame(aa,index=['first','second','third'])
bb
Out[7]:
one three two
first 1 3 2
second 2 4 3
third 3 5 412345671234567
2.从多维数组中创建
import numpy as np
In [9]: del aa
In [10]: aa=np.array([[1,2,3],[4,5,6],[7,8,9]])
In [11]: aa
Out[11]:
array([[1, 2, 3],
[4, 5, 6],
<