Questions tagged [counter]

A Counter is a container(/bag/multiset/etc.) that keeps track of how many times equivalent values are added.

In Python:

A Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.

http://docs.python.org/library/collections.html#collections.Counter


5262 questions
1
vote
2 answers

less common words in a python list

I have done the counter of most common words to keep only the 128 most common words in my list in order: words = my_list mcommon_words = [word for word, word_count in Counter(words).most_common(128)] my_list = [x for x in my_list if x in…
Eduardo Andrade
  • 111
  • 1
  • 1
  • 13
1
vote
1 answer

Iteration counter Python3x

So I've built a simple calculator in Python where the user inputs two numbers and an operator and the answer is given. They also have the option to run the calculator again. I want to number the answers so each answer reads "Answer 1 equals x",…
user9378126
1
vote
1 answer

Timer0 as counter with Microchip PIC10F202

I developing RC switch for my RC glider. I have microkontroller Microchip PIC10F202 and I have problem with ON/OFF LED Lights. I want triggering input PPM signal from RC receiver, I setted GP2 as input (by T0CKI and count for every rise edge - from…
1
vote
1 answer

Formula to count number of occurrences of a particular word per month in excel

I'm trying to create a formula that'll tell me how many times a particular word in column B occurs per month. I've got the dates down column A. For example, I would like to know how many time the word "car" appears in column B in February, March &…
1
vote
2 answers

In Python. I have a list of ND arrays and I want to count duplicate arrays in order to calculate an Average for each Duplicate array value

I have a list of ND arrays(vectors), each vector has a (1,300) shape. My goal is to find duplicate vectors inside a list, to sum them and then divide them by the size of a list, the result value(a vector) will replace the duplicate vector. For…
Art
  • 91
  • 2
  • 10
1
vote
4 answers

Is w3schools example about javascript closure practically useless?

I was reading this example on w3schools about Javascript closure applied to the "counter dilemma": https://www.w3schools.com/js/js_function_closures.asp In practical use, this example seems almost nonsense. Why should I wrap the variable "counter"…
Lore
  • 1,286
  • 1
  • 22
  • 57
1
vote
1 answer

How can I find the number of items or movies under a specific genre or category in a given data set of movies.

I have already completed the separation of the genres for movies now I want to get the number of movies under each each genre, following is my completed code for separating the genres df['geners_arr']=df['genres'].str.split('|') …
Ddevil Prasad
  • 117
  • 1
  • 14
1
vote
3 answers

Appending items to a list and ensuring unique name by incrementing number

This is a commonly asked question but I've not found an answer on searches that meets the exact kind of thing I'm trying. I have a list of items with similar names and I want to add them with a number suffix so that each time, if a duplicate exists,…
cvw76
  • 99
  • 1
  • 9
1
vote
1 answer

Adding a counter in vb.net for an sql-query output

Right now I'm working on a simple program in vb.net. Choose 2 dates in the daytimepicker, press a button for an sql-query and save the result somewhere. This works fine, but now I want to add an counter to the query. One column just has the numbers…
AVK
  • 21
  • 2
1
vote
1 answer

Count characters in textarea onload

I'm trying to create a simple tool to count the length of a title/meta description. I managed to create the character counter (without jQuery). However, upon page load there is a default text entered in each textarea and I would like it to be…
TheGeek
  • 13
  • 3
1
vote
2 answers

How to check if button has been clicked

I have a bunch of dynamic buttons which I am setting an onClickListeners as they are produced, as well as tagging them with IDs. Not sure if this a simple one which I have just spent too much time staring at but this is the problem. If a user clicks…
Display name
  • 730
  • 2
  • 8
  • 23
1
vote
1 answer

Get the number of characters between two patterns that are in the next line of a line that begins with '>' in a large file

First of all, sorry about the extensive size of the title, i could't find a better what to explain where i want to get to with this bash script. I have a very large file (multifasta) that looks like…
Fernanda Costa
  • 85
  • 1
  • 10
1
vote
2 answers

count number of clicks/spacebar in given time javascript

Basically, I wanna make a game which counts number of space bar presses/button clicks in 10 seconds. I made a countdown timer, and counter both are working fine I could not find a way to stop counting key-press (after timer stops) so i have used…
Amit Soni
  • 94
  • 1
  • 1
  • 6
1
vote
1 answer

Include Counter in array JSONata

I just started using JSONata and I found it quite fascinating to parse JSON easily. But I have this problem, and I'm not sure if it can be done with JSONata directly. I want to include a counter that goes from 1 to "the number of objects in an…
1
vote
1 answer

Use user input and configfile to write to a new file

I am pretty new to coding, and I am attempting to have a user input words (zones). I want these to be put into a list that can be used to pull from based on the counter. The rest of the input is being pulled from a file and then then broken up using…