pandas.DataFrame 的 iloc
# ------------------------------------------------------------
'python式的切片,包含为尾位置'
In [23]:df = pd.DataFrame({
'http_status': [200,200,404,404,301],
'response_time': [0.04, 0.02, 0.07, 0.08, 1.0]},
index=[0,1,2,3,4]) In [26]:df[1:3]
Out[26]:
http_status response_time
1 200 0.02
2 404 0.07 In [24]:df.iloc[1:3,:]
Out[24]:
http_status response_time
1 200 0.02
2 404 0.07 In [28]:df.values[1:3,:]
Out[28]:
array([[ 2.00000000e+02, 2.00000000e-02],
[ 4.04000000e+02, 7.00000000e-02]]) # ------------------------------------------------------------
'matlab式的切片,包含尾位置'
In [29]:df.ix[1:3,:]
Out[29]:
http_status response_time
1 200 0.02
2 404 0.07
3 404 0.08