做个笔记,根据列A统计列B的数量

需求描述:

根据列username,对列subject的数量进行统计

 

表的记录集:

+----+---------+----------+

| id | subject | username |

+----+---------+----------+

|  1 | 记录一  | admin    |

|  2 | 记录二  | admin    |

|  3 | 记录三  | admin    |

|  4 | 记录四  | test1    |

|  5 | 记录五  | test2    |

|  6 | 记录六  | test2    |

+----+---------+----------+

 

需要的结果:

+----------+-----+

| username | num |

+----------+-----+

| admin    |   3 |

| test1    |   1 |

| test2    |   2 |

+----------+-----+

 

 

SQL:select username,count(subject) as num from 表名 group by username

 

蓝桥杯刷题总结:Java中的A+B=C A-B=C的数对统计问题 本文对比了统计满足A+B=C和A-B=C数对个数的哈希表与双指针解法。哈希表有全量统计和边存边统计两种版本:全量版先统计频次再相乘求和,适用于两种运算;边存边统计版仅适用于A+B=C,因其对称性。双指针需先排序,A+B=C用对向指针,A-B=C用同向指针。关键区别在于A+B=C对称可互换,而A-B=C不对称需区分顺序。推荐使用全量统计哈希表法,适用性更广且不易出错。 阅读详情

相关推荐

华为od统一考试B卷【统计文本数量】JavaScript 实现

有一个文件,包含以一定规则写作的文本,请统计文件中包含的文本数量

MISAYAONE的博客 5031

excel基于一列的值统计另一列数值的个数

1. 源数据是A列与B列,在C列统计A列值相等时,在B列不同取值的个数,在C1输入如下的公式,再双击单元格的右下角的小正方形即可 C1结果计算过程: 第一步: (A$1:A$6=A1)返回一个数组{TRUE;FALSE;FALSE;TRUE;FALSE;FALSE},数组大小跟A$1:A$6相同,分别比较A$1:A$6各元素与A1是否相等,相等取TRUE,不相等为FALSE 第二步:COUNTIFS(A$1:A$6,A$1:A$6,B$1:B$6,B$1:B$6),返回一个数组...

C_lazy的专栏 1万+

华为od统一考试B卷【统计文本数量】Python 实现

有一个文件,包含以一定规则写作的文本,请统计文件中包含的文本数量

MISAYAONE的博客 5782

datafrme按某列分类并统计每类数量

import os import re import difflib import pandas as pd import threading import numpy as np #读入数据 data=pd.read_csv(r"C:\Users\Administrator\Desktop\26263.csv",header=0,encoding = 'gb2312') print(data) #遍历每行,加1 list_tongji = [] for index, row in data.iterrow

weixin_43789661的博客 1809

华为云CodeHub代码托管

什么是代码托管 代码托管(CodeHub)是面向软件开发者的基于Git的在线代码托管服务,是具备安全管控、成员/权限管理、分支保护/合并、在线编辑、统计服务等功能的云端代码仓库,旨在解决软件开发者在跨地域协同、多分支并发、代码版本管理、安全性等方面的问题。 代码托管具有以下特性 · 在线代码阅读、修改、提交,随时随地开发,不受地域限制。 · 在线分支管理,包含分支新建、切换、合并,实现多分支并行开发,效率高。 master分支:最为稳定,功能比较完整,随时可发布的代码。 develop分支:用于平时开

LUJINYUANA的博客 1万+

基因树构建全流程:从OrthoFinder到iTOL的保姆级教程(附兰科植物案例)

本文提供了一份从OrthoFinder到iTOL的基因树构建全流程保姆级教程。详细解析了利用OrthoFinder构建物种树、IQ-TREE构建无根基因树、Notung进行树调和生根,以及最终在iTOL中实现专业可视化的每一步操作与实战经验,并以兰科植物NB-ARC基因家族为例进行演示,帮助研究者系统掌握基因树分析方法。

tequila的博客 523

c++ 用类统计不及格人数_办公 这16个Excel函数,帮你完成80%的数据统计工作

在日常工作中,数据统计是工作中最重要的一部分。今天小编把Excel中最常用的统计函数整理了出来,共16个。为了方便同学们理解,选取的全是贴近应用的示例。1Count 函数作用:统计数字的个数示例:使用公式生成A列的序号=COUNT(A$1:A1)+1注:大小不一的合并单元格填充公式,要使用Ctrl+Enter完成。2Counta函数作用:统计非空单元格个数示例:下表D:F列中,如果填充“...

weixin_36240219的博客 369

嵌入式Linux Qt应用程序卡死问题分析记录

根据应用和系统层面的分析,软件功能异常和卡死现象的原因是系统控制台/dev/console阻塞导致依赖其的相关应用和命令异常。系统控制台/dev/console阻塞的原因还未确定,最近的软件版本和其他测试同事未出现该问题,所以很大可能是串口线的问题,待后续有进展了继续更新。

V10_x的博客 1644

写一条SQL语句,统计表中a、b两列值相同的数量,将大于1的记录打印出来。

如图,基于一张表(test01)筛选有相同数据的指定的列(a、b)。 select * from test01 t where (   select count(1) from test01 where a = t.a and b = t.b)>1 结果: 转载于:https://www.cnblogs.com/henry0/p/10840744.html...

weixin_30906701的博客 1141

瑞芯微rk3568移植openbmc(一)----关于ob移植的优缺点

基于rock3a的单板,CPU为瑞芯微rk3568的环境,移植了openbmc

feixiang3839的专栏 5537

【微信小程序开发与设计】垃圾智能分类小程序

垃圾分类是将来生活可持续发展的必需项。但是很多人由于缺乏垃圾分类知识,或是因为垃圾分类困难,费时费力,所以没有好好贯彻垃圾分类政策,此时设计一款方便于群众进行智能化垃圾识别分类的微信小程序就显得尤为必要。

Markelle_Fultz的博客 8245

Excel查询A列和B中重复的有多少条记录

•快速统计COUNTIF或COUNTIFS函数。•可视化标记:条件格式。•批量处理:高级筛选或数据透视表。选择适合数据规模的方法即可。如需进一步优化,可提供具体数据示例。

gulihua10086的博客 3533

Homebrew国内镜像自动安装全攻略:从零到精通

本文提供了一份详尽的Homebrew国内镜像自动安装指南,旨在帮助Mac用户,特别是国内开发者,快速、无痛地部署这一强大的包管理器。通过使用优化的国内镜像脚本,实现一键自动安装,有效解决官方源访问缓慢或失败的问题。文章从安装前准备、脚本执行步骤、原理讲解到日常使用命令和常见问题排查,提供了从零到精通的完整路径,让用户在短时间内掌握Homebrew的核心用法,提升开发与工作效率。

a0b1c2d3的专栏 968

excel-如何统计A列有值且B列同一行无值或者为公式的数量?

统计A列有值且B列同一行无值或者为公式的数量。

cgscct的博客 1362

北斗导航 | 卫星导航接收机原理(基础)

卡尔曼滤波,最小二乘,伪距,芯片,模组,接收机,捕获,跟踪,RTK,RTD,PPP,SPP,多普勒,DOP,灵敏度,热启动,冷启动,PNT,北斗发展,MEO,IGSO,GEO,ICD,导航电文,载波,载噪比

尘世冰封的专栏 2342

微信小程序:errno: 1500104, errCode: 10008, errMsg: “writeBLECharacteristicValue:fail:system error, status

微信小程序errno: 1500104, errCode: 10008, errMsg: "writeBLECharacteristicValue:fail:system error, status: UNKNOWN (239)"微信小程序调用蓝牙API,wx.writeBLECharacteristicValue()报错,微信小程序蓝牙写入错误,在开发uniapp微信小程序蓝牙通信功能时报错,蓝牙开发设备控制核心api,微信小程序调用蓝牙API “wx.writeBLECharacteristicValu

✅ 精选推荐文章 3930

wps表格筛选A列在B列中的数据

3、C列中,为0的代表数据不在B列,为1代表在,可以根据C列数据进行筛选了。2、在C列输入公式=countif(A:A,C1),然后enter。

Saber190919的专栏 2124

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

python实现统计dataframe某列里的某个元素的数量、并且根据数量排序(超级简单)

写一个python小脚本的时候遇到一个问题,如何统计dataframe某列里的某个元素的数量、并且根据数量排序。 比如,dataframe[‘week’] 里,周一有5个,周二有8个… 然后排序的时候,周二排在周一前面。 代码如下: #针对target 数据 根据数量进行排序 data_target=data['target'] #得到针对target的去重 data_target_de_dup=data['target'].drop_duplicates() #建立一个map 实现按照target的计

weixin_45564533的博客 1万+

深度学习工具包 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")

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

kibana 统计数量_常用的数据统计Sql 总结

1. 统计各个条件下的数据selectBatchId,sum(CardSum) 总金额,sum(case when Status=1 then CardSum else 0 end) as 已使用,sum(case when Status=2 then CardSum else 0 end) as 已冻结 from GiftCard group by BatchId2. 统计每日,每月,每年的数据...

weixin_39765625的博客 2146

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

excel技巧-如何统计A列有值且减去B列同一行无值或者为公式的数量?

统计A列有值且排除掉B列同一行无值或者为公式的数量。

cgscct的博客 605

mysql统计同一个值出现_如何使用MySQL查询某个列中相同值的数量统计

如何使用MySQL查询某个列中相同值的数量统计数据现在是这样的,我想确定出type列中的news和image。。。。甚至以后有其他值,他们分别有多少个。SELECTtype,count(1) AS countsFROMmaterialGROUP BYtypecount(1),代表统计第一列,写上1 比写 *的效率高!以上所述就是本文的全部内容了,希望大家能够喜欢。时间: 2015-07-19前言 ...

weixin_39621975的博客 2302

Excel统计某列重复值数量方法

1,COUNTIF函数 比如要统计重复的列为A列,在要统计的A列隔壁插入一空列B列,在要统计的数据第一列对应位置输入公式=COUNTIF(A:A,A2),然后将公式向下填充,即可得到整列的重复统计数据。 =COUNTIF(A:A,A2) 解读:A:A 选择A列自动填充,A2 代表要在A列中统计重复数量的值为A2 countif函数,第一个参数为要统计的列,第二个参数为要统计重复的值。 ...

wh445306 9526

python统计各种数量_python 统计列表中不同元素的数量方法

python 统计列表中不同元素的数量方法刚刚上网搜了一下如何用python统计列表中不同元素的数量,发现很少,找了半天。我自己来写一种方法。代码如下list=[1,1,2,2,3]print(list)set1=set(list)print(set1)print(len(set1)) #len(set1)即为列表中不同元素的数量得到结果:[1, 1, 2, 2, 3]{1, 2, 3}3原理就是...

weixin_32129187的博客 7592

Excel-选出A列中存在,B列中不存在的元素

=IF(COUNTIF($B$1:$B$30,A1)>0,A1,"") A列 A1,A2,A3,A4,A5 B列 A2,A3 选中C1,输入=IF(COUNTIF($B$1:$B$30,A1)>0,A1,""),shift+enter,向下填充到c5, 选中C列,选择扩展选定区域,按升序排列, A列中,把对应C列的内容删除,剩下的就是想要的结果 参考资料: Excel,从A列中选出在B列中不存在的值 https://blog.youkuaiyun.com/xzg1109/ar...

野生码农 6888

统计Excel列中某值出现的次数

统计Excel列中某值出现的次数

晴天的博客 1万+
上一篇: 发布一个JS抽奖小程序
下一篇: E编辑器在Cygwin环境下Zen coding初体验
gwikimo
博客等级 码龄18年 4粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值