Questions tagged [counting]

Counting is the action of finding the number of elements of a finite set of objects.

Counting is the action of finding the number of elements of a finite set of objects. The traditional way of counting consists of continually increasing a (mental or spoken) counter by a unit for every element of the set, in some order, while marking (or displacing) those elements to avoid visiting the same element more than once, until no unmarked elements are left; if the counter was set to one after the first object, the value after visiting the final object gives the desired number of elements. The related term enumeration refers to uniquely identifying the elements of a finite (combinatorial) set or infinite set by assigning a number to each element.

Counting using tally marks at Hanakapiai Beach Counting sometimes involves numbers other than one; for example, when counting money, counting out change, "counting by twos" (2, 4, 6, 8, 10, 12, ...), or "counting by fives" (5, 10, 15, 20, 25, ...). There is archeological evidence suggesting that humans have been counting for at least 50,000 years. Counting was primarily used by ancient cultures to keep track of social and economic data such as number of group members, prey animals, property, or debts (i.e., accountancy). The development of counting led to the development of mathematical notation, numeral systems, and writing.

1837 questions
6
votes
3 answers

How to use R dplyr's summarize to count the number of rows that match a criteria?

I have a dataset that I want to summarize. First, I want the sum of the home and away games, which I can do. However, I also want to know how many outliers (defined as more than 300 points) are within each subcategory (home, away). If I wasn't using…
J.Sabree
  • 2,280
  • 19
  • 48
6
votes
2 answers

Overlapping Objects issue in Counting Insects with OpenCV

I'm trying to count the number of a group of crickets(insect). I will use the image processing method, by openCV library. This will provide more accuracy practice, when the farmers sell their crickets. The photo was taken from a smartphone.…
APC
  • 61
  • 1
6
votes
3 answers

Is there a method in Pytorch to count the number of unique values in a way that can be back propagated?

Given the following tensor (which is the result of a network [note the grad_fn]): tensor([121., 241., 125., 1., 108., 238., 125., 121., 13., 117., 121., 229., 161., 13., 0., 202., 161., 121., 121., 0., 121., 121., 242., 125.], …
jwelch1324
  • 61
  • 1
  • 1
  • 3
6
votes
2 answers

How to use variable range in Google Sheets?

Currently I have such formula: COUNTIFS(B3:B36,"16",E3:E36,"01") Would it be possible to turn these ranges B3:B36 and E3:E36 into variables, like B'start_cell_value':B'stop_cell_value'. The whole thing would look like: …
6
votes
3 answers

How rename pd.value_counts() index with a correspondance dictionary

I am doing a value_counts() over a column of integers that represent categorical values. I have a dict that maps the numbers to strings that correspond to the category name. I want to find the best way to have the index with the corresponding…
Adrien Pacifico
  • 1,649
  • 1
  • 15
  • 33
6
votes
8 answers

Finding count of tuples with same first and third item in list of tuples

I have a list of tuples each with three items : z = [(1, 4, 2015), (1, 11, 2015), (1, 18, 2015), (1, 25, 2015), (2, 1, 2015), (2, 8, 2015), (2, 15, 2015), (2, 22, 2015), (3, 1, 2015), (3, 8, 2015), (3, 15, 2015), (3, 22, 2015), (3, 29, 2015), (4, 5,…
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
6
votes
5 answers

groupby a column and count items above 5 in another pandas

So I have a df like this: NAME TRY SCORE Bob 1st 3 Sue 1st 7 Tom 1st 3 Max 1st 8 Jay 1st 4 Mel 1st 7 Bob 2nd 4 Sue 2nd 2 Tom 2nd 6 Max 2nd 4 Jay 2nd 7 Mel 2nd 8 Bob 3rd…
DLB
  • 101
  • 2
6
votes
6 answers

Fastest way to count number of bit transitions in an unsigned int

I'm looking for the fastest way of counting the number of bit transitions in an unsigned int. If the int contains: 0b00000000000000000000000000001010 The number of transitions are: 4 If the int contains: 0b00000000000000000000000000001001 The…
tormod
  • 73
  • 1
  • 6
6
votes
3 answers

Optimal/fastest way to count dates in a python list

I have a list of dates and the goal is to count the occurrences of each date while maintaining the order in which they appear in the original list. Consider the following example: The list only_dates looks like this: [datetime.date(2017, 3, 9),…
Ravindra S
  • 6,302
  • 12
  • 70
  • 108
6
votes
8 answers

Counting the number of occurrences of words in a textfile

How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word. For example, if the input is something like: "the man said hi to the boy." Each of "man said hi to boy" would have an…
vinc456
  • 2,862
  • 5
  • 23
  • 30
6
votes
5 answers

select count(*) vs keep a counter

Assuming indexes are put in place, and absolute-count-accuracy is not necessary (it's okay to be off by one or two), is it okay to use: Option A select count(*) from Table where Property = @Property vs Option B update PropertyCounters SET…
Lou
  • 63
  • 1
  • 4
6
votes
10 answers

Efficient way of counting True and False

This may be a trivial problem, but I want to learn more about other more clever and efficient ways of solving it. I have a list of items and each item has a property a whose value is binary. If every item in the list has a == 0, then I set a…
ChrisG
  • 149
  • 2
  • 6
6
votes
6 answers

Trying to determine length of a string using recursion in C++

int count(string s){ if(s == "") return 0; if(s.length == 1) return 1; return 1 + count() //This is what I can't figure out. How to traverse the string. //I just need a hint, not a full on answer. } I dont know how to…
corn_flakes
  • 85
  • 1
  • 8
6
votes
2 answers

Counting the number of words in a string, C++

Possible Duplicate: C++ function to count all the words in a string So I have a line of words which i stored in a string using C++. i.e. "There was a farmer named Billy\n" I want to know the number of words in the string (i.e. There are currently…
Masterminder
  • 1,127
  • 7
  • 21
  • 31
6
votes
3 answers

perl: count unique elements in array

I have a simple array with names in it, and I want to be able to easily print out the number of times each name appears. I have tried making a ton of for loops an diff statements to first make another array with unique values then, trying to count…
Ten Digit Grid
  • 1,315
  • 4
  • 22
  • 43