-
Dataframe
Dataframe數(shù)據(jù)類型由共用相同索引的數(shù)據(jù)組成款票,常用于二維數(shù)據(jù)
行 column:axis=1; 列 index:axis=0
-
創(chuàng)建
- 二維ndarray對象
- 一維ndarray筹陵、列表泼诱、字典想罕、元組状答、Series構成的字典
- Series類型
- 其他Dataframe類型
- 二維ndarray創(chuàng)建
import numpy as np
import pandas as pd
d = pd.DataFrame(np.arange(10).reshape(2, 5))
print(d)
Out:
0 1 2 3 4
0 0 1 2 3 4
1 5 6 7 8 9
- 一維ndarray對象字典創(chuàng)建
dt = {'one':pd.Series([1, 2, 3], index=['a','b', 'c']),
'two':pd.Series([9, 8, 7, 6],index=['a', 'b', 'c', 'd'])}
b = pd.DataFrame(dt)
print(b)
Out:
one two
a 1.0 9
b 2.0 8
c 3.0 7
d NaN 6
- 列表類型的字典創(chuàng)建
dl = {'one':[1, 2, 3, 4],
'two':[9, 8, 7, 6]}
c = pd.DataFrame(dl, index=['a', 'b', 'c', 'd'])
print(c)
Out:
one two
a 1 9
b 2 8
c 3 7
d 4 6