Questions tagged [find-occurrences]
435 questions
32
votes
3 answers
Show count of occurrences when smart highlighting in Notepad++
Is it possible to show the number of occurrences of words which are smart highlighted? I mean when you double click on a word.
In Matlab e.g. smart highlighting is activated by having the cursor touching a word and in the tool bar it instantly says…

embert
- 7,336
- 10
- 49
- 78
25
votes
3 answers
Create counter within consecutive runs of values
I wish to create a sequential number within each run of equal values, like a counter of occurrences, which restarts once the value in the current row is different from the previous row.
Please find an example of input and expected output…

Richard
- 1,224
- 3
- 16
- 32
21
votes
4 answers
Count occurrences of a value in a column of an array of object arrays
Does anyone know how to count the occurrences of "photo" in this array:
Array (
[0] => stdClass Object ( [type] => photo [id] => 1404781893036 [created_time] => 2012-03-02T07:58:23+0000 )
[1] => stdClass Object ( [type] => photo [id]…

Georg
- 610
- 2
- 8
- 22
15
votes
3 answers
Print 10 most frequently occurring words of a text that including and excluding stopwords
I got the question from here with my changes. I have following code:
from nltk.corpus import stopwords
def content_text(text):
stopwords = nltk.corpus.stopwords.words('english')
content = [w for w in text if w.lower() in stopwords]
…

user2064809
- 403
- 1
- 4
- 13
13
votes
6 answers
Count occurrences of value in a set of variables in R (per row)
Let's say I have a data frame with 10 numeric variables V1-V10 (columns) and multiple rows (cases).
What I would like R to do is: For each case, give me the number of occurrences of a certain value in a set of variables.
For example the number of…

nilsole
- 1,663
- 2
- 12
- 28
12
votes
5 answers
Find the position of the first occurrence of any number in string
Can someone help me with algorithm for finding the position of the first occurrence of any number in a string?
The code I found on the web does not work:
function my_offset($text){
preg_match('/^[^\-]*-\D*/', $text, $m);
return…

Gasper
- 959
- 3
- 11
- 29
8
votes
4 answers
Bash: substring from first occurrence of a character to the second occurrence
In bash, how do I get a substring of everything from the first occurrence of a character to the second occurrence of the same character.
Example...
Input String = "abc-def-ghi"
Character = "-"
Desired Output String = "def"

Stephen Walsh
- 815
- 4
- 18
- 34
8
votes
1 answer
How to replace all occurences except the first one?
How to replace all the repeated words except the first one in the string? That is these strings
s='cat WORD dog WORD mouse WORD'
s1='cat1 WORD dog1 WORD'
will be replaced to
s='cat WORD dog REPLACED mouse REPLACED'
s1='cat1 WORD dog1 REPLACED'
I…

Ooker
- 1,969
- 4
- 28
- 58
8
votes
3 answers
Match a pattern only once
I have a string
foo-bar-bat.bla
I wish to match only foo
My flawed pattern matches both foo and bar
\w+(?=-.*\.bla)
How do I discard bar? Or maybe even better, how could I stop matching stuff after foo?

wawiwa
- 313
- 1
- 5
- 9
7
votes
3 answers
How to calculate a (co-)occurrence matrix from a data frame with several columns using R?
I'm a rookie in R and currently working with collaboration data in the form of an edge list with 32 columns and around 200.000 rows. I want to create a (co-)occurrence matrix based on the interaction between countries. However, I want to count the…

Seb
- 179
- 1
- 8
5
votes
0 answers
Find Number of times a particular character appears in a string using MDX query
In the Microsoft SSAS, I have a dimension column that contains multiple values separated by the special character | in a single row as below.
Example value of a row: Image|Video|Audio|
Requirement:
So, I need to count the number of values present in…

Sathish G
- 91
- 3
5
votes
3 answers
How to compute similarities based on co-occurrence matrix?
I have an item-item matrix (1877 x 1877). The values in the matrix represent the number of times two items occurred together. How can I determine the similarities between two items?
Through reading, i found few options. However i am not sure about…

kitchenprinzessin
- 1,023
- 3
- 14
- 30
5
votes
3 answers
python 3.4 Counting occurrences in a .txt file
I am writing a "simple" little program for a class i am taking. this is supposed ask me for what team to search for and then return the number of times it appears on the list in a .txt file. it requests input like it should and seems to run great!…

Qwastic
- 59
- 1
- 2
- 5
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 <-…

nomi
- 91
- 7
4
votes
1 answer
How can I find start and end occurrence of character in Python
I have a dataframe df with the following ids (in Col).
The last occurrence of A/B/C represents the start, and the last occurrence of X is the end. I should ignore any other A,B,C between start and end (e.g. rows 8 and 9).
I have to find start and…

ckp
- 579
- 2
- 10
- 27