Questions tagged [find-occurrences]
435 questions
1
vote
1 answer
C - Function that counts the number of occurrences of an element in a randomized array
I'm kinda new to programming overall and are currently programming in C, and I'm currently working on a program that first randomizes 10 numbers that are put into an array and prints them out on the screen, and then let the user enter an integer and…

ConfusedChicken4
- 41
- 6
1
vote
2 answers
The occurrence of the biggest number in a list
So, after searching the internet for hours, though I found some related stuff, still could not find what I am looking for. In my code I provide 6 inputs. After that input I have managed to insert them into a list(), and find the biggest number with…

neverbeagod
- 19
- 1
1
vote
2 answers
Count each occurrence of each element in a string
I would like to count occurrences for each single character in a string and output them to a dataframe.
Here is my try:
q.data<-data.frame(number=1,string=c("COUNTTHESECHARACTERS"))
q.data[,3]<-string.counter(strings=q.data$string,…

user2904120
- 416
- 1
- 4
- 18
1
vote
1 answer
Python calculate co-occurrence of tuples in list of lists of tuples
I have a big list of lists of tuples like
actions = [ [('d', 'r'), ... ('c', 'e'),('', 'e')],
[('r', 'e'), ... ('c', 'e'),('d', 'r')],
... ,
[('a', 'b'), ... ('c', 'e'),('c', 'h')]
…

jcosta
- 21
- 1
1
vote
3 answers
Find multiple occurrences of words in a string and store the respective staring indices
BACKGROUND
I have a string of text and a hash set that contains words that i am looking for.
Given
String doc = "one of the car and bike and one of those";
String [] testDoc = doc.split("\\s+");
HashSet setW = new…

Dinero
- 1,070
- 2
- 19
- 44
1
vote
2 answers
Find an occurrence in a table column using panda
I'm a complete beginner using Python and I'm trying to find a way to know how much Female and Male I have in my table.
I've imported my table and printed it but don't know how to find occurrences in my columns
tableur =…

AmZaliAn
- 21
- 1
1
vote
0 answers
How to find most occurring elements in a list when there are many such elements?
I am working on a problem that returns maximum occurring elements in a list.
I am able to achieve this using mode in statistics. But when there are more than one element that repeats most, the mode function is throwing StatisticsError. How do I get…

user10849817
- 31
- 6
1
vote
1 answer
MS Excel: Find First Occurrence of Specific Text within a String Using Column Range List
Using a MS Excel formula that finds and extracts the very first (1st) instance/occurrence of a specific word found within a Column range of Keywords.
In Cell A2 I have a sub-string of text containing the following:
Karen was born in Akron, OH and…

Miaka3
- 339
- 1
- 10
- 27
1
vote
1 answer
R add newlines to every nth occurrence of blank
Mytext is a long string delimited by blank space.
Mytextsample <- "aaaaabb cccdddd eee adssdada ooeoeo ososs ksdkd
ooeresso osososososos krrr dkdkkd odlcjs kdcmcmc ddddd dmssss"
I tried to add a new line every 10th blank using regular…

Hwang
- 13
- 2
1
vote
4 answers
Replace second occurrence of a string in one column based on value in other column in R
Here is a sample dataframe:
a <- c("cat", "dog", "mouse")
b <- c("my cat is a tabby cat and is a friendly cat", "walk the dog", "the mouse is scared of the other mouse")
df <- data.frame(a,b)
I'd like to be able to remove the second occurrence of…

carozimm
- 109
- 7
1
vote
2 answers
How do I get the number of occurrences of a list of words (substrings) in a pandas dataframe?
I have a pandas data frame with approximately 1.5 million rows. I want to find the number of occurrences of specific, selected words (which are all known) in a certain column. This works for a single word.
d =…

dnclem
- 2,818
- 15
- 46
- 64
1
vote
2 answers
How do I return the first index/occurrence of a last name (a given string) using Binary Search?
I am working on an assignment for my class and the goal of this function is to use Binary Sort on an array of a struct, and return the index of the very first location that a last name is found (even if there are multiple last names, just return the…

Scranton Branch
- 23
- 2
1
vote
2 answers
Counting occurrences of a specific element in list after a character in Prolog?
So with this code I believe I'm quite close but I think I messed it up when trying to count 'w' in a list only after a 'b' and not before. For example h1([w,w,b,w,b,b],H) would succeed with H=1.
EDIT: I believe my base cases are correct. But the…

TubaShark
- 25
- 6
1
vote
2 answers
Check if set of items occurrs in row MySQL
I am working with big datasets in MySQL (combined with Java) and trying to implement a Frequent Itemset algorithm.
A recurring aspect of the algorithm is counting how many times a set of items (an item is a random integer) occurs in the dataset.…

DataWarrior Niño
- 33
- 3
1
vote
5 answers
replace every second word with the word 'hello' using a function
Im new to python and programming. I have been given a task to complete that asks the following question:
Create your own function that takes in a sentence and replaces every second word with the word “Hello”
my approach was to separate the sentence…

Kevin
- 17
- 1
- 3