2016.12.09回顾 dataframe获取某一个值的索引

DataFrame通过行、列索引,获取指定位置的值 客户需求 DataFrame通过行、列索引,获取指定位置的值 阅读详情

1、我上午玩了会儿joinquant,按照自己的算法实现一些卖点,进行回测比较

2、改良了一个风控系统方面的功能

3、要记录股票的市值排名,学习了一下pandas.dataframe的用法,我要在dataframe中取出索引,最后是把dataframe的某一列拿出来,也就是说是一个series,然后用list()或者tolist()方法把series转换成list,然后对于list中没有重复的value的时候,然后用list.index(value)可以返回value在list中的索引值,有重复value的话就会返回第一个索引值

4、然而有时候觉得自己方法很make sense,但是实际用起来还不如之前的,不那么讲道理的方法(至少我没看出来逻辑合理性)

pandas dataframe series根据值获取标签(索引),根据索引获取值 如何得到series:https://blog.csdn.net/qxqxqzzz/article/details/101296187 # 根据值获取索引 series1[series1.values == 1].index # 根据索引获取值 series1['a'] 阅读详情

相关推荐

爬取国家统计局最近10年年度数据

一、编码流程 1.目标网址:https://data.stats.gov.cn/easyquery.htm?cn=C01 2.编码思路: (1) 解析左侧指标树,实现4级标签定位 (难点:层层嵌套,下一级指标的xpath路径以上一级指标为基础;不是所有二级指标都含有三和四级指标,需要进行判断) (2) 使用selenium webdriver 点选指标,加载出右侧表格数据 (难点:当指标无法在全局页面显示时,需向下拖动滚动条) (3) 解析右侧数据,实现数据存储 3.使用模块: (1) selenium:解

weixin_39645690的博客 4558

Pandas

函数:loc[]:根据行或者列标签获取数据#获取单行数据,返回结果是Series,该对象的索引是DataFrame的列索引#获取多行数据#通过切片获取多行数据,(切片包括终止值),结果返回DataFrame#通过行标签和列标签获取数据,返回结果是一个标量。

2201_75550838的博客 609

Deep Reinforcement Learning - 1. DDPG原理和算法

Deep Reinforcement Learning - 1. DDPG原理和算法 背景描述 DDPG的定义和应用场景 DDPG算法相关基本概念定义 DDPG实现框架和算法 DDPG对于DPG的关键改进 下一篇 以下用RL作为Reinforcement Learning 的简称。背景描述概括来说,RL要解决的问

kenneth_yu的博客 14万+

pandas 返回值的索引

【代码】pandas 返回值的索引。

weixin_42118352的博客 1835

想在 Visual Studio Code 里进行 ABAP 开发,需要安装的扩展列表

安装完毕后,我们可以将 SAP 系统配置为 Visual Studio Code 连接的远程文件系统。为了连接到 SAP 系统,需要启用 ABAP 开发工具 (ADT) ICF 节点,这与 SAP Hana Studio 等工具使用的服务相同。打开 SAP GUI 并连接到目标系统,运行事务 SICF,然后激活 ADT_SRV 服务,如下所示。这启用了允许代码编辑器和 IDE 连接到 SAP 系统的服务。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 3119

Buck电源设计常见的一些问题(一)半桥栅极驱动芯片共性失效问题

半桥驱动芯片主要用在器件可应用于电信,数据通信,便携式存储或更低电压系统中的电源转换器,半桥、全桥、推挽、同步降压,正激变换器和同步整流器等方面。当然难免会遇到不少问题。基本上我们在产品开发的过程中都遇到过栅极驱动芯片坏掉的情况,所以找了一些资料,学习学习。也查找查找原因。

小幽余生不加糖 2369

获取DataFrame的值的索引以及其他

1、可以用DataFrame的条件索引,即令df_sub=df[conditions],然后再获取df_sub的index属性即可 2、对于某一个列,可以先转化为list类型,然后利用list.index(values)方法获取索引,其中若有重复着,则返回第一个值对应的索引 3、list.count(value)可返回value在list中的个数 4、DataFrame.count()返回每...

S_o_l_o_n的博客 8793

2025华为OD 面试手撕代码真题【字符串至多删除一个字符,是否能构成回文串】

2025华为OD 面试手撕代码真题【字符串至多删除一个字符,是否能构成回文串】

MISAYAONE的博客 1706

python中Pandas之DataFrame索引、选取数据

python中Pandas之DataFrame索引、选取数据

weixin_46713695的博客 2万+

基于YOLOv10的机器人抓取引导系统:从物体检测到精准抓取

python# 数据标注工具简化版import os"""启动标注工具""""""标注单张图像"""print(f"标注图像: {os.path.basename(img_path)}")print("请在图像上绘制抓取矩形框...")# 这里应该实现交互式标注界面# 简化版本直接返回示例标注# 示例标注数据"""保存标注结果"""# 保存为YOLO格式# 转换为YOLO格式。

YOLO 377

2023最新多文明策略手游《万国觉醒内购版》最新整理Linux商业手工服务端+安卓+详细搭建教程

2023最新多文明策略手游《万国觉醒内购版》最新整理Linux商业手工服务端+安卓+详细搭建教程。源码内置详细搭建教程,感兴趣可自行下载。

百创科技 1713

Python: csv、dataframe、h5 与 pandas、h5py的一些尝试

本来想写一个库,看能不是提高pandas处理dataframe持久化成h5的读写速度,结果是无功而返,速度差距很大。 感觉难点之一在数据转换上,现在还没有很好的办法。做个标记,也算是对h5折腾的一个回顾。 # -*- coding: utf-8 -*- #import tools import os import pandas as pd import os.path import numpy a...

代码过客 3995

数仓建模—维度建模之维度表

首先要学会识别维度,维度是相对稳定的、可抽象具有共性的、固有的(天然的)描述度量或事实的上下文属性信息,失去维度信息的度量信息是没有意义的或者说是失去维度信息的事实表是没有意义的。其次要掌握维度表的设计原则和设计流程,从而更加科学的设计维度表,其实这些东西都是术,我们一直都说一句话大道至简,其实如果你掌握了精髓,抛开这些术也可以做到得心应手,这就像张无忌练太极剑一样,忘记了才能达到道的境界,也就是无我,如果做不到就记住这些原则加以应用从而达到术的境界。

2401_84052244的博客 4361

DataFrame基础操作巩固——股票分析(一)

中国股票排名第一的茅台酒的股票数据分析案例,比较细节

qq_47250064的博客 1327

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Apache Beam 2021 年设计提案索引:52 份 dev 邮件列表文档与它们在仓库中的落地

本文基于 Apache Beam 仓库中的年度文档索引 [2021.md](https://link.gitcode.com/i/4af39d21652d5653c86a8922e9083eaa),完整收录 2021 年提交给 `dev@beam.apache.org` 邮件列表的 52 份设计提案(作者、主题、UTC 时间),并结合 [generate_doc_md.py](https://li

gitblog_00242的博客 999

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

2017.05.09回顾 pandas使用记录

1、给决策引擎P2做了一个伪接口方便测试,做完伪接口还剩1个多小时,我他妈干什么了呢?我怎么想不起了 2、下午主要就是思考Simon留下的那个问题,几乎思考了一下午,把结论写在了上次挖坑的地方 3、下午同时也解决了加解密的问题,那个软件可以授权进程就ok了 4、晚上主要是写程序解决最佳同盾多头阈值寻找的问题,在这个过程中,我再一次熟悉了pandas的很多用法 读取csv成dataf

strwolf的专栏 884

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

pandas dataframe 得到某一值所在的行索引

随便假设一个数据框: import csv import pandas as pd data = {"year": [2010, 2011, 2012, 2013], "month": [1, 2, 3, 4], "date": [5, 6, 7, 8]} df = pd.DataFrame(data) print(df) 找到指定数值所在行索引: # 找到指定数值所在行索引: # 比如2012年所在的行索引 index = df[df.year == 2012].index.tolist()[

yutingwu816的博客 7万+

python pandas查找DataFrame中指定数据的索引

查找DataFrame中特定值的索引举个例子,代码演示:1,创建一个DataFrame2,寻找数据中columns列名 ~BoolCol=30~ 和 ~attr=44~ 所在的行索引3,返回列表中的4就是满足条件的索引 举个例子,代码演示: 1,创建一个DataFrame import pandas as pd df = pd.DataFrame({'BoolCol': [10, 20, 30, 30, 40],'attr': [22, 33, 22, 44, 66]},index=[1,2,3,4

weixin_44346972的博客 2万+

dataframe索引总结

df[]的参数只能传入一个维度,要么是行索引,要么是列索引,不能同时传入行索引和列索引。 df[]生成的结果有的是series,有的是dataframe。 df[]传入一个值或一个列表时,传入的是列索引。传入行索引时,只能传入切片。 .loc和.iloc的参数可以有值、列表、切片三种方式。传入值时,结果是series,传入列表和切片时,结果是dataframe。 .loc和.iloc的参数通过逗号分为两部分,前面是行索引或下标,后面是列索引或下标,列索引可以省略,但行索引不能省略。 ...

m0_46172703的博客 4524

pandas.DataFrame获取满足某条件的行、元素所在的索引(index)

dataframe中根据某些条件得到特定的行或者特定的元素,如何找出这些行、元素所在的index,也就是行号。 _temp = {'job':['farmer', 'teacher', 'worker', 'acter', 'present'], 'money':[3000, 7000, 5000, 100000, 66666]} df = pd.DataFrame(_temp) print(df...

漫步量化 6万+

如何获取dataframe的某个column的值为某值的行的index和行号

如下代码,column a为0的index 为1 行号为0      a   b   c 1   0   2  4 2   1   3  5 import pandas as pd import numpy as np data_frame = pd.DataFrame({'a':[0,1],'b':[2,3],'c':[4,5]}) data_frame.index = [1,2] ...

ruguowoshiyu的博客 1万+

pyspark.sql DataFrame 根据索引顺序读取某行某列的一个具体值

在上述方法中,第一种和第二种方法需要将部分或全部数据加载到内存中,可能会导致内存不足的问题。第三种方法使用Window函数和row_number()函数处理数据,具有更好的性能和内存效率,尤其是在处理大型数据集时。不过,需要注意的是,为了确保行号的正确性,需要在Window.orderBy()函数中指定一个合适的排序列。在本示例中,使用了"id"列进行排序。

Gemini 3620

获取dataframe中某列中某几个值对应的index索引

例如:获取num 列中,值在num_with_fault中的值对应的index num_with_fault=[1,2,4] df['num'] =[3,4,2,55,6] index_with_fault = df[df.loc[:,'num'].isin(num_with_fault)].index 则:index_with_fault = [1,2] ...

qq_41598736的博客 2万+

获取dataframe中的某几个值 对应的索引

取出特定条件 转list ch_index=list(userItem[userItem[‘***']==nature]['客户姓名']) 用isin 找寻 seriesItem.loc[:,'客户姓名'].isin(ch_index)].index

weixin_42653353的博客 3121

Python pandas read_html返回值List,DataFrame索引方法(行,列索引,行列索引)示例 | dataframe移除空行列、移除行列、数据格式化小数位、百分比、千分位分隔

什么情况下返回值是List,什么时候是DataFrame 如何把List转换为DataFrame 如何打印表格及如何保存到Excel表格 如何行索引 如何列索引 如何行列索引 pandas dataframe 方法示例 pandas dropna()移除空行、空列 pandas drop() 删除列 pandas drop() 删除行 DataFrame数据格式化 (设置小数位数) DataFrame数据格式化 (设置百分比) DataFrame数据格式化 (设置千分位分隔符)

CDamogu 3193

Pandas 中根据列值,选取DataFrame数据,并获取行索引号列表

一、根据列条件,获取行索引号并转成列表#在dataframe中根据一定的条件,得到符合要求的某些行元素所在的位置import pandas as pd df = pd.DataFrame({'BoolCol': [1, 2, 3, 3, 4],'attr': [22, 33, 22, 44, 66]}, index=[10,20,30,40,50]) print(df) ...

huang_susan的博客 10万+
上一篇: 2016.12.08回顾 SQL模块化与子查询 SELECT NULL变换 JOINQUANT探索
下一篇: 2016.12.12回顾
strwolf
博客等级 码龄18年 84粉丝 336原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值