码迷,mamicode.com
首页 > 编程语言 > 详细

[Python Cookbook] Pandas: Indexing of DataFrame

时间:2019-02-11 10:50:28      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:ram   f11   amt   ilo   can   ber   string   frame   code   

Selecting a Row

df.loc[index] # if index is a string, add ‘ ‘; if index is a number, no ‘ ‘

or

df.iloc[row_num]

 

Selecting a Column

df[col_name]

Or

df.col_name

 

Selecting an Element

df.loc[index, col_name]

Selecting Multiple Discontinuous Rows

df.loc[[row_num1, row_num2, ...]] # can‘t use df.iloc here

Or 

df.loc[bool_expr]

 E.g.

nyc[nyc.cand_nm.isin(df11 p.cand nm)]
nyc[nyc.cand_nm.isnull()]
nyc[nyc.cand_nm.isnull()]
nyc[nyc.contb_receipt_amt >0]

 

[Python Cookbook] Pandas: Indexing of DataFrame

标签:ram   f11   amt   ilo   can   ber   string   frame   code   

原文地址:https://www.cnblogs.com/sherrydatascience/p/10360730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!