如何在DataFrame索引某一行
有行索引和列索引
df=DataFrame(np.arange(16).reshape((4,4)),index=['a','b','c','d'],columns=['one','two','three','four'])
df
Out[14]: one two three four
a 0 1 2 3
b 4 5 6 7
c 8 9 10 11
d 12 13 14 15
po=df.loc[['a','b'],:]
po
Out[16]: one two three four
a 0 1 2 3
b 4 5 6 7
默认的索引
dd=DataFrame(np.arange(81).reshape((9,9)))dd
Out[20]: 0 1 2 3 4 5 6 7 8
0 0 1 2 3 4 5 6 7 8
1 9 10 11 12 13 14 15 16 17
2 18 19 20 21 22 23 24 25 26
3 27 28 29 30 31 32 33 34 35
4 36 37 38 39 40 41 42 43 44
5 45 46 47 48 49 50 51 52 53
6 54 55 56 57 58 59 60 61 62
7 63 64 65 66 67 68 69 70 71
8 72 73 74 75 76 77 78 79 80
pp=dd.loc[[1,5,7],:]pp
Out[25]: 0 1 2 3 4 5 6 7 8
1 9 10 11 12 13 14 15 16 17
5 45 46 47 48 49 50 51 52 53
7 63 64 65 66 67 68 69 70 71
如何在DataFrame索引某一行相关推荐
- 如何在 Pandas DataFrame 中插入一行
您可以使用以下基本语法将行插入到 Pandas DataFrame 中的特定位置: import pandas as pd import numpy as np#insert row with val ...
- dataframe索引筛选_筛选的索引:性能分析和隐藏成本
dataframe索引筛选 介绍 (Introduction) Filtered indexes are well documented, as they have been around in SQ ...
- 通过整数索引选择一行熊猫系列/数据框
本文翻译自:Selecting a row of pandas series/dataframe by integer index I am curious as to why df[2] is no ...
- python中Pandas之DataFrame索引、选取数据
目录 1.索引是什么 1.1 认识索引 1.2 自定义索引 2. 索引的简单使用 2.1 列索引 2.1.2 使用loc和iloc 2.2 行索引 2.2.1 使用[ : ] 2.2.2 使用.loc ...
- python dataframe增加一行_python - 在pandas.DataFrame中添加一行
python - 在pandas.DataFrame中添加一行 据我所知,pandas旨在加载完全填充的DataFrame,但我需要创建一个空的DataFrame,然后逐个添加行.做这个的最好方式是什 ...
- pandas中dataframe索引排序实战:pandas中dataframe索引降序排序、pandas中dataframe索引升序排序
pandas中dataframe索引排序实战:pandas中dataframe索引降序排序.pandas中dataframe索引升序排序 目录
- python3-pandas DataFrame 索引、bool索引、pandas 字符串方法
1.DataFrame 索引 1.1 普通索引取值 pandas 取行或者列的注意点: 方括号写数组,表示取行,对行进行操作 方括号写字符串,表示取列,对列进行操作 import pandas as ...
- Pandas DataFrame索引和列属性
Pandas DataFrame index and columns attributes allow us to get the rows and columns label values. Pan ...
- 怎么在html中加横条,如何在HTML中插入一行?html横线标签hr全新讲解
对于刚刚入门的新手不知道如何在HTML中插入一行?那么接下来我们认识一下html横线标签hr. 一:html横线标签hr属性 标签主要是在html中创建水平线,hr是单标签,是没有结束标签的,而且所有 ...
最新文章
- Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
- k8s nodeport无法访问_k8s学习之service详解
- iOS开发UI中懒加载的使用方法
- php如何做熔断降级,spring cloud 如何实现服务熔断服务降级
- 4. 分类的线性模型
- react 引用本地js_从零配置webpack 4+react脚手架(二)
- 简单的策略模式Strategy演示
- 简单3步成功给Mac安装指定Python版本和指定库版本并且随意切换版本,非常简单,不行拿砖砸我
- iservice封装有哪些方法_对WebService的一些封装技巧总结
- Python3 Socket和SocketServer 网络编程
- 2015/08/24
- ASP.NET MVC实现网站验证码功能
- hdoj 1071 The Area 求面积
- mysql 能用compute_SQL compute by 的使用
- 用C语言开发一个BT下载软件(一) ------ BitTorrent协议 -2
- DynDNS免费动态域名解析
- Unity-URP-基于模板的延迟渲染
- Spark 推测执行 /spark.speculation=true /spark.speculation.quantile=0.75/spark.speculation.multiplier=1.5
- Stateful Firewall和SPI(stateful packet inspection) Firewall介绍
- echarts 折线图高于目标显示绿色低于目标显示红色