Python|Python Pandas (1)

import pandas as pd
Series a = pd.Series([1,2,3,4],index=['a','b','c','d'])
.reindex #改index
.drop #删除index
dataframe 二位数组 import pandas as pd
a = pd.Series([1,2,3,4],index=['a','b','c','d'])
b = pd.Series([2,23,3,4],index=['a','b','c','d'])
c= pd.Series([6,2,37,4],index=['a','b','c','d'])
m={'x':a,'y':b,'z':c}
n=pd.DataFrame(m)
x y z
a 1 2 6
b 2 23 2
c 3 3 37
d 4 4 4
数据清洗 数据提取
print (n.iloc[1,1])
print(n.iloc[0:2,:])
print(n.loc['b','x'])
新增行
f=[5,5,7]
n.loc['f',:]=f
顺序
【Python|Python Pandas (1)】n=n.sort_values(by=['x'],ascending=False)

    推荐阅读