
关于pandas中iloc和loc的差异及条件取值方法详解
5星
- 浏览量: 0
- 大小:None
- 文件类型:PDF
简介:
本篇文章详细解析了Pandas库中的iloc与loc两种索引方式的区别,并介绍了基于条件进行数据筛选的方法。
使用DataFrame的loc方法取某几行几列的数据:
```python
print(df.loc[0:4, [item_price_level, item_sales_level, item_collected_level, item_pv_level]])
```
结果如下,取了index为0到4的五行四列数据。
| item_price_level | item_sales_level | item_collected_level | item_pv_level |
|------------------|------------------|----------------------|---------------|
| 3 | 3 | 4 | 14 |
| 3 | 3 | 4 | 14 |
| 3 | 3 | 4 | 1 |
注意,第三行最后一列的值为“1”,而非原文中的“1,”。
全部评论 (0)
还没有任何评论哟~


