新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:pythoniloc用法
隨機(jī)生DataFrame 類(lèi)型數(shù)據(jù):

| A | B | C | D | |
| a | 0.560094 | 0.352686 | 0.954100 | 0.926277 |
| b | 0.563728 | 0.335517 | 0.232902 | 0.973932 |
| c | 0.482155 | 0.976618 | 0.565462 | 0.445108 |
| d | 0.477146 | 0.933353 | 0.291764 | 0.986668 |
iloc 基于行索引和列索引(index,columns) 都是從 0 開(kāi)始
如果數(shù)據(jù)的行標(biāo)簽和列標(biāo)簽名字太長(zhǎng)或不容易記,則用 iloc 很方便,只需記標(biāo)簽對(duì)應(yīng)的索引即可
### .loc先行后列,中間用逗號(hào)(,)分割,例如取 a 和 A 對(duì)應(yīng)的數(shù)據(jù) frame.iloc[0,0]
0.56009394013943303
### 取前兩行對(duì)應(yīng)數(shù)據(jù)
frame.iloc[0:2,:]
### 取前兩列對(duì)應(yīng)數(shù)據(jù) frame.iloc[:,0:2]
### 上面的例子取的都是連續(xù)的行和列,若取第一行和第四行、第一列和第四列對(duì)應(yīng)的數(shù)據(jù),則 frame.iloc[[0,3],[0,3]]
網(wǎng)站名稱(chēng):創(chuàng)新互聯(lián)Python教程:pythoniloc用法
標(biāo)題鏈接:http://m.fisionsoft.com.cn/article/dpsddpd.html


咨詢(xún)
建站咨詢(xún)
