Pandas 查找元素方法:loc、iloc、at、iat、query、布尔索引
在 Pandas 中,要查找元素可以使用以下方式:
-
'loc' 方法:用于通过行标签和列标签选取数据,例如 df.loc['row_label', 'column_label']。
-
'iloc' 方法:用于通过行索引和列索引选取数据,例如 df.iloc[row_index, column_index]。
-
'at' 方法:用于通过行标签和列标签快速选取单个数据,例如 df.at['row_label', 'column_label']。
-
'iat' 方法:用于通过行索引和列索引快速选取单个数据,例如 df.iat[row_index, column_index]。
-
'query' 方法:用于通过表达式查询数据,例如 df.query('column_name == value')。
-
布尔索引:用于通过布尔值筛选数据,例如 df[df['column_name'] == value]。
原文地址: https://www.cveoy.top/t/topic/njtW 著作权归作者所有。请勿转载和采集!