Questions tagged [find-occurrences]
435 questions
1
vote
2 answers
Get the row with first occurrence of repetitive value in column using SQL Server
Suppose I have this table
Id Order Value
------------------
aa 0 'cat'
ba 1 'dog'
bb 2 'yuk'
dc 3 'gen'
ca 4 'cow'
c1 5 'owl'
b0 7 'ant'
h9 8 'fly'
t4 9 'bee'
g2 10 'fox'
ea 11 …
user5113188
1
vote
1 answer
Calculating the Occurrence of a Value based on 2 data
I have an array that looks like this:
Arr=[{"cause" : 1 , "solution" : "change"},
{"cause" : 1 , "solution" : "rechange"},
{"cause" : 2 , "solution" : "alter settings"},
{"cause" : 1 , "solution" : "change"},
{"cause" : 3 ,…

Sriram
- 433
- 4
- 20
1
vote
1 answer
How to create occurrence matrix from dynamic graph?
I have list of edges from dynamic graph as shown below
G1=nx.read_edgelist('m_enron_employees_1Sorted.txt',create_using=nx.MultiGraph(), nodetype=int)
print(G1.edges())
[(13, 48), (13, 48), (13, 48), (13, 48), (13, 48), (13, 48), (13, 48),
(13,…

TinaTz
- 311
- 3
- 16
1
vote
2 answers
R function that return a vector with position occurence of each value?
I am searching for a function that return a vector with the position/count of each value of a vector.
Here an example :
I have :
vec<-c("A","A","A","B","B","C")
I want :
c(1,2,3,1,2,1)
I have created a function that works but I am looking for a…

Adeline Morisot
- 37
- 2
1
vote
1 answer
Filter words only instead of punctuations
I'm attempting to go through lists of positive ('pos') and negative ('neg') lists essentially. Issue here is that the script below is including out white-space and punctuation also, and I don't want that. I would like to only extract the most common…

Polacan
- 55
- 5
1
vote
4 answers
How to find the two strings that occurs most in a list?
I'm trying to get the number of the two elements that are the most frequent in an array. For example, in the list ['aa','bb','cc','dd','bb','bb','cc','ff'] the number of the most frequent should be 3(the number of times 'bb' appear in the array) and…

one user
- 109
- 9
1
vote
4 answers
Count Occurrences of Seven Integers in Array
I have written the code below and it has comments attached. The application is to read seven integers entered by the user. The application then prints out the number of occurrences of each of the seven values.
The program crashes when I enter in the…

davramirez
- 11
- 4
1
vote
2 answers
C Check all occurrences of a letter appear before another letter
So i have a string S consisting of N letters 'a' or 'b'.
This should return 1 if all occurrences of A are before all occurrences of b and return 0 otherwise.
B does not need to occur in S and A does not need to occur in S
For example
S='aabbb'…

ScuffedCoder
- 376
- 1
- 5
- 21
1
vote
2 answers
Get the most common element of an array using Pyspark
How can I get the most common element of an array after concatenating two columns using Pyspark
df = spark.createDataFrame([
[['a','a','b'],['a']],
[['c','d','d'],['']],
[['e'],['e','f']],
[[''],['']]
]).toDF("arr_1","arr2")
df_new =…

John Doe
- 9,843
- 13
- 42
- 73
1
vote
2 answers
Find and count all occurrences and position of numbers in a range in a list
I want to find the number of times each number appears at each index position in a list of 6 number sets when I do not know what the numbers will be, but they will range from 0-99 only.
Example list:
data = [['22', '45', '6', '72', '1', '65'], ['2',…

Josh Crouse
- 343
- 1
- 13
1
vote
1 answer
Scaled Co-occurrence matrix with window size calculation in python
Say, I've a dataset in CSV format, which contains sentences/paragraphs in rows.
Suppose, it looks like this:
df = ['A B X B', 'X B B']
Now, I can generate co-occurrence matrix that looks like this
A B X
A 0 2 1
B 2 0 4
X 1 4 0
Here, (A,B,X) are…

AtanuCSE
- 8,832
- 14
- 74
- 112
1
vote
1 answer
Extract text between each two occurrences of a string into a new file
I have an input file that looks like this:
DATA-GROUP A
text 1
text 2
text 3
DATA-GROUP B
text 4
text 5
text 6
etc.
How can I extract each occurrence of the string "DATA-GROUP" and the lines beneath it until (but not including) the next…

user13758913
- 23
- 4
1
vote
1 answer
How to print occurrences of numbers in Scala?
I am new to Scala.
Kindly help me with the expected output
val list =List(1,123,2,3,123,1,2)
val result = aList.map(x => aList.count(_==x)))
println(result.distinct)
Expected Output: Number of occurrence of 1 is 2
…

smp97
- 63
- 6
1
vote
1 answer
Count item occurrences in an array with mongodb aggregation framework
I am working in a project with express and mongodb (I am using mongoose) and I have a collection whith the following structure:
[
{
"_id": "5e4a39f01ab49e48d4db5b9c",
"last": {
"winningNumbers": {
"list": [
…

atheodos
- 131
- 12
1
vote
1 answer
Conditional occurrences of specific strings and relatively making a new data frame using R
I have a big data frame with 4 columns and many rows (an example is attached).
#what I have
Arm <- c("5prime","3prime","5prime","CoMature","3prime","5prime","3prime","3prime")
Family <-…

Apex
- 1,055
- 4
- 22