counting

counting data and grouping by week in mysql

非 Y 不嫁゛ 提交于 2019-11-29 12:32:05
this is my DB table: CREATE TABLE IF NOT EXISTS `inspection_report` ( `Inspection_datetime` datetime NOT NULL, `Line` char(5) NOT NULL, `S` int(11) NOT NULL, `A` int(11) NOT NULL, `B` int(11) NOT NULL, `C` int(11) NOT NULL, INSERT INTO `inspection_report` (`Inspection_datetime`,`Line`,`S`, `A`, `B`, `C`) VALUES ('2010-09-01 09:08:01','FA 05',0, 0, 0, 0),('2010-09-02 14:24:35','FA 07',0, 0, 1, 0),('2010-09-01 09:08:01','fa 05',0, 1, 1, 0),('2010-09-01 16:24:04','FA 03', 0, 1, 0, 0); I have a lot of data for this table.how do i do if i want show the result like: Line 1st week 2nd week 3rd week

Efficiently count the number of occurrences of unique subarrays in NumPy?

こ雲淡風輕ζ 提交于 2019-11-29 10:02:31
I have an array of shape (128, 36, 8) and I'd like to find the number of occurrences of the unique subarrays of length 8 in the last dimension. I'm aware of np.unique and np.bincount , but those seem to be for elements rather than subarrays. I've seen this question but it's about finding the first occurrence of a particular subarray, rather than the counts of all unique subarrays. The question states that the input array is of shape (128, 36, 8) and we are interested in finding unique subarrays of length 8 in the last dimension. So, I am assuming that the uniqueness is along the first two

Function to count number of digits in string

和自甴很熟 提交于 2019-11-29 05:28:27
问题 I was looking for a quick PHP function that, given a string, would count the number of numerical characters (i.e. digits) in that string. I couldn't find one, is there a function to do this? 回答1: This can easily be accomplished with a regular expression. function countDigits( $str ) { return preg_match_all( "/[0-9]/", $str ); } The function will return the amount of times the pattern was found, which in this case is any digit. 回答2: first split your string, next filter the result to only

Count the number of Ks between 0 and N

巧了我就是萌 提交于 2019-11-28 17:39:56
Problem: I have seen questions like: count the number of 0s between 0 and N? count the number of 1s between 0 and N? count the number of 2s between 0 and N? ... ... These kinds of questions are very similar of asking to find the total number that Ks (i.e. K=0,1,2,...,9) are shown in number range [0, N] . Example: Input: K=2, N=35 Output: 14 Detail: list of 2 s between [0,35] : 2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32 , note that 22 will be counted as twice (as 22 contains two 2 s) What we have: There are solutions for each of them (available if you search for it). Usually, O(log N)

Finding the number of digits of an integer

不打扰是莪最后的温柔 提交于 2019-11-28 16:19:02
What is the best method to find the number of digits of a positive integer? I have found this 3 basic methods: conversion to string String s = new Integer(t).toString(); int len = s.length(); for loop for(long long int temp = number; temp >= 1;) { temp/=10; decimalPlaces++; } logaritmic calculation digits = floor( log10( number ) ) + 1; where you can calculate log10(x) = ln(x) / ln(10) in most languages. First I thought the string method is the dirtiest one but the more I think about it the more I think it's the fastest way. Or is it? Mike Dunlavey There's always this method: n = 1; if ( i >=

How to count the characters in a string with Batch? [closed]

我是研究僧i 提交于 2019-11-28 14:22:14
I need to count the characters of an inputed string in Batch. I don't want to use temporary files. Could it be done without them? If yes, explanations of your code would be greatly appreciated. Thanks SO! A simple way is to use a function @echo off set "myVar=abcdefg" call :Stringlength result myVar echo %result% exit /b :Stringlength <resultVar> <stringVar> ( setlocal EnableDelayedExpansion set "s=!%~2!#" set "len=0" for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do ( if "!s:~%%P,1!" NEQ "" ( set /a "len+=%%P" set "s=!s:~%%P!" ) ) ) ( endlocal set "%~1=%len%" exit /b ) This can

PHP - Count duplicate values within two dimensional array, then display only unique values with the count

末鹿安然 提交于 2019-11-28 14:10:27
I've been working on this for a couple days now... and still haven't been able to achieve my desired results. Any help would on this would be greatly appreciated... thank you in advance. I have a multi-array stored in $log, which displays like this when you print_r($log): Array ( [0] => Array ( [0] => Red [1] => Steel ) [1] => Array ( [0] => Red [1] => Wood ) [2] => Array ( [0] => Blue [1] => Wood ) ) Currently I have this: $counts = $log; foreach ($log as $value) { foreach ($value as $k => $v) { if (!isset($counts[$k])) $counts[$k] = array(); if (!isset($counts[$k][$v])) $counts[$k][$v] = 0;

How to print count of occourance of some string in the same CSV file using Python?

拟墨画扇 提交于 2019-11-28 12:06:01
问题 I have a CSV file in which contains one column (column1). I want to check whether the element in cell repeats and how many times(occcurance_count).And print count of occurrence in the same CSV file using Python. In the below example the "241682-27638-USD-OCOF" is not repeating so the count is one, "241942-37190-USD-DIV" is repeated twice so the count is 2 and so on. Want the output as below in CSV format column1 ,occcurance_count 1682-27638-USD-OGGCOF ,1 241682-27638-USD-OGGINT ,1 241682

Count the number previous items in by group in R [duplicate]

…衆ロ難τιáo~ 提交于 2019-11-28 10:57:12
问题 This question already has an answer here: Adding a counter column for a set of similar rows in R [duplicate] 1 answer I would like to create a new variable which counts the number of previous items in a by group. Here is what I mean, taking the esoph dataset as an example. first I sort the dataset by my by group esoph$agegp, esoph$alcgp and an additional value column -esoph$ncontrols . This gives me the following dataset x<-esoph[order(esoph$agegp, esoph$alcgp, -esoph$ncontrols ), ] x agegp

counting data and grouping by week in mysql

妖精的绣舞 提交于 2019-11-28 06:47:40
问题 this is my DB table: CREATE TABLE IF NOT EXISTS `inspection_report` ( `Inspection_datetime` datetime NOT NULL, `Line` char(5) NOT NULL, `S` int(11) NOT NULL, `A` int(11) NOT NULL, `B` int(11) NOT NULL, `C` int(11) NOT NULL, INSERT INTO `inspection_report` (`Inspection_datetime`,`Line`,`S`, `A`, `B`, `C`) VALUES ('2010-09-01 09:08:01','FA 05',0, 0, 0, 0),('2010-09-02 14:24:35','FA 07',0, 0, 1, 0),('2010-09-01 09:08:01','fa 05',0, 1, 1, 0),('2010-09-01 16:24:04','FA 03', 0, 1, 0, 0); I have a