count

Count unique distinct values if condition is true

给你一囗甜甜゛ 提交于 2020-01-15 22:25:11
问题 I try to count the unique values in list but they have to fulfill the condition I have set. {=SUM(IF($A$1:$A$25=$D$2; 1/COUNTIF($B$1:$B$25; $B$1:$B$25); 0))} There the first 25 rows of the data as example. How to count unique distinct values if condition is true in Excel? 回答1: Just will posting the question, I found the answer: {=SUM(IF($D$1=$A$1:$D$25, 1/(COUNTIFS($A$1:$A$25; $D$2; $B$1:$E$25; $B$1:$B$25)); 0))} 来源: https://stackoverflow.com/questions/33213119/count-unique-distinct-values-if

Count and print number of files in subfolders using Python

回眸只為那壹抹淺笑 提交于 2020-01-15 07:40:10
问题 My folder structure is as follows Folder A Folder B1 Folder B2 .... Folder Bn How can I count the number of files in each of the folders (Folder B1 - Folder Bn), check if the number of files is larger than a given limit and print the folder name and number of files in it on the screen? Like this: Folders with too many files: Folder B3 101 Folder B7 256 Here's what I've tried so far. It goes through every subfolder in each of my Folder B1 etc. I just need file count in one level. import os,

Insert data if number of rows is greater than 0 does not work

五迷三道 提交于 2020-01-14 06:52:10
问题 I have this PHP function which will insert urls into MySQL, but only those which didn't exist until moment of executing. I have a problem, my if condition is simply ignored, so everything goes to database, ignoring the condition. Code is here: function storeLink($url,$gathered_from) { global $conn; $querycheck = "SELECT COUNT(*) FROM test WHERE link = '$url'"; $resultcheck = mysqli_query($conn, $querycheck); $row = mysqli_fetch_array($resultcheck, MYSQLI_ASSOC); if($row['COUNT(*)'] < 1); {

How to update the URI of the webpage automatically?

▼魔方 西西 提交于 2020-01-14 05:47:08
问题 I have a table called files where there are columns such as id, name, webpage, visitors. There are list of files already in the table. Now I have created new columns called webpage and visitors. The webpage is the URI of the file and the visitors is the counter views of the file. The problem is that I wanted to update the webpage and visitors automatically using session but I can't. Can you please help me. <?php session_start(); include_once"config.php"; $webpage=htmlspecialchars($_SERVER[

SQL select multiple counts in the last 12 months including missing months

此生再无相见时 提交于 2020-01-14 02:54:07
问题 I've been trying to create a SQL Query that returns a result that looks something like this: May 2013 P1 0 May 2013 P2 5 May 2013 P3 2 May 2013 P4 1 June 2013 P1 3 June 2013 P2 2 June 2013 P3 4 June 2013 P4 9 July 2013 P1 0 July 2013 P2 0 July 2013 P3 5 July 2013 P4 2 The idea is I've got two tables Priority and Work: Priority: Name|Value P1 9 P2 7 P3 5 P4 2 ... Work: ID | PriorityValue | CompleteTime 1 9 03/04/2013 2 5 02/09/2013 3 7 12/01/2014 4 9 11/02/2014 How do I generate count for each

Count rows with 1 or more NaNs in a Dataframe

三世轮回 提交于 2020-01-13 17:09:14
问题 I have the following: print(df.isna().sum()) Which gives me: city 2 country 0 testid 0 house 1807 house_number 248 po_box 1845 zipcode 260 road 132 state 1 state_district 1817 suburb 1800 unit 1806 I want the total number of rows that have 1 or more NaN values from columns city, state, zip, and house Thanks for any suggestions. 回答1: This is how I would use isna and sum : cols = ['city', 'state', 'zip', 'house'] df[df[cols].isna().sum(axis=1) > 0] Another option is calling dropna and checking

Count each condition within group

空扰寡人 提交于 2020-01-13 08:27:23
问题 For every unique GroupId I would like to get a count of each IsGreen , IsRound , IsLoud condition and a total number of rows. Sample data: ----------------------------------------------------- id | ItemId | GroupId | IsGreen | IsRound | IsLoud ----+--------+---------+---------+---------+--------- 1 | 1001 | 1 | 0 | 1 | 1 2 | 1002 | 1 | 1 | 1 | 0 3 | 1003 | 2 | 0 | 0 | 0 4 | 1004 | 2 | 1 | 0 | 1 5 | 1005 | 2 | 0 | 0 | 0 6 | 1006 | 3 | 0 | 0 | 0 7 | 1007 | 3 | 0 | 0 | 0 Desired result: --------

Count number of distinct values in a vector

时光毁灭记忆、已成空白 提交于 2020-01-13 07:39:31
问题 I have a vector of scalar values of which I'm trying to get: "How many different values there are". For instance in group <- c(1,2,3,1,2,3,4,6) unique values are 1,2,3,4,6 so I want to get 5 . I came up with: length(unique(group)) But I'm not sure it's the most efficient way to do it. Isn't there a better way to do this? Note: My case is more complex than the example, consisting of around 1000 numbers with at most 25 different values. 回答1: Here are a few ideas, all points towards your

Count number of distinct values in a vector

纵饮孤独 提交于 2020-01-13 07:39:07
问题 I have a vector of scalar values of which I'm trying to get: "How many different values there are". For instance in group <- c(1,2,3,1,2,3,4,6) unique values are 1,2,3,4,6 so I want to get 5 . I came up with: length(unique(group)) But I'm not sure it's the most efficient way to do it. Isn't there a better way to do this? Note: My case is more complex than the example, consisting of around 1000 numbers with at most 25 different values. 回答1: Here are a few ideas, all points towards your

including missing (zero-count) rows when using GROUP BY

主宰稳场 提交于 2020-01-13 03:48:30
问题 I have an application that receives sms messages. What i want to do is make a statistic with mysql that will count meessages in a hour. For example in 7 am i received 10 sms messages, in 8 am i received 20 etc. My table has this columns ID, smsText, smsDate ... (others are not important). When i run this script: SELECT HOUR(smsDate), COUNT(ID) FROM SMS_MESSAGES GROUP BY HOUR(smsDate) it show how many messages i get in every hour. The problem is when i dont receive any message for example in