Questions tagged [multiple-occurrence]

17 questions
4
votes
2 answers

adding a column to df that counts occurrence of a value in another column

What I am trying to do is adding a column by "places" that count the id occurrence in the whole column "id' : id <- c(204850, 204850, 204850,312512,312512,452452,285421,758412,758412,758412) places <-…
2
votes
1 answer

Count and rank-order co-occurrences of entities across dates and locations in MySQL

I need to build a SQL script to count how many times pairs of different entities appeared in the same DATE and LOCATION. On any given date, there will be multiple locations and many entity IDs. I need to find out how often PAIRS of entities were at…
2
votes
1 answer

How to use regex to get multiple occurrences of formula in PHP

I want to extract each arithmetic formula from this string: +100*25-30 I used this regex: preg_match_all("/(([\*\+\-\/])([0-9]+\.?[0-9]*))+/", "+100*25-30", $match); It is capturing only last occurrence which is -30 but if I enter space before…
Jamol
  • 3,768
  • 8
  • 45
  • 68
2
votes
4 answers

Merge two flat arrays and omit values from one array when the other array has more occurrences of the same value

I want to merge every element of two arrays, BUT if a value is in both arrays, then only add the values from the array which has the biggest amount of that element. The result array does not need to be sorted in any special way, but I did it here…
1
vote
2 answers

String search by coincidence?

I just wanted to know if there's a simple way to search a string by coincidence with another one in Python. Or if anyone knows how it could be done. To make myself clear I'll do an example. text_sample = "baguette is a french word" words_to_match =…
1
vote
2 answers

how to find the maximum occurrence of a string in string array in c++

I have a string array like {"A", "B", "AA", "ABB", "B", "ABB", "B"} how do I find the string ( "B" ) which occurs the largest number of times in an array like this in c++? Thank you
user15014634
0
votes
0 answers

Print the column data of a data frame based on the condition on consecutive numbers

I would like to print all the columns data from the below data where the consecutive values should be (for 14 continuous minutes or longer). it means (1,2,.....14) will definitely come and if I have these consecutive values means greater than 14…
0
votes
2 answers

To find the next word of a particular word as often as possible from a string with python

I'm working with Python,I need to find next substring of all order-ids using python code. str = """Delivered-To: example@gmail.com\r\nReceived: by 2002:a05:7022:2496:b0:41:f6c7:a91b with SMTP id cq22csp1730422dlb;\r\n Sat, 2 Jul 2022 06:28:47…
0
votes
2 answers

python random int append to list and count "x" top numbers that occurred and number of times int occurred

New to python so all help is appreciated! I did check and found several count post but couldn't find any that print the top occurrences from the list. (ie 3 occurred 6x, 4 occurred 4x and 2 occurred 3x) Goal: I'd like to have the code print 1000…
user16826661
0
votes
1 answer

From count to cases in R

I have a dataset with a column which indicate the number of occurence of a group constituted by multiples variables. Here SEXand COLOR. CASES <- base::data.frame(SEX = c("M", "M", "F", "F", "F"), COLOR = c("brown",…
0
votes
1 answer

Count the occurrences of a wordlist within a string observation

I've a list of the top 10 most occurring words the abstract of academic article. I want to count how many times those words occur in the observations of my dataset. The top 10 words are: top10 = ['model','language','models','task', 'data', 'paper',…
0
votes
4 answers

Python Codewars: can someone explain how/why this happens?

I'm doing Codewars and got stuck at this simple question. The question was: Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result. It should remove all values from list a, which…
0
votes
2 answers

How to count the number of occurances in an array and translate it into an array of object?

I am trying to take in an array of names (with duplicates) and output a array of objects. Input: single array const arr = ['M', 'M', 'M', 'S', 'S', 'S', 'R', 'C', 'S', 'S', 'S'] Output: array of objects [ { name: 'M' duplicates: 3 }, …
Tyler Morales
  • 1,440
  • 2
  • 19
  • 56
0
votes
1 answer

How many duplicated record into Mysql table

I have a table called "people". I want to check if there are duplicates. ID | NAME | AGE | ----|------|-----| 1 | Max | 21 | 2 | Tom | 30 | 3 | Jim | 45 | 4 | Jim | 45 | 5 | Max | 21 | 6 | Max | 21 | 7 | Tom | 30 | 8 …
Massimo
  • 1
  • 1
0
votes
2 answers

MS Excel: Extract between the Nth and Nth Character in a string

Using an MS Excel formula (No VBA/Macro), I would like to extract between the Nth and Nth characters and/or letters in a string. Example: I have text in Columns A2 and A3, I would like to extract text located between the 4th space and 9th space in…
Miaka3
  • 339
  • 1
  • 10
  • 27
1
2