find-occurrences

MySQL : replace occurence of a string in field except first one

有些话、适合烂在心里 提交于 2020-01-17 07:03:13
问题 I want to update all fields of a column, a lot of them have a desired string in there, but I want this string to be in only each field once, for instance : "MyString OtherString MyString AnotherString AndAnother MyString" to "MyString OtherString AnotherString AndAnother" would you have any idea on how to achieve this ? 回答1: If "MyString" will always occur as the first term in the field, this would work: update MyTable set MyField = replace(MyField, ' MyString','') The key point above is that

python 3.4 Counting occurrences in a .txt file

本小妞迷上赌 提交于 2020-01-13 18:07:08
问题 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! its been running for an hour now :) i am getting no errors at all it seems to be stuck in a loop. thank you all in advance for your help! here is my code count = 0 def main(): # open file teams = open('WorldSeriesWinners.txt', 'r') # get input who =

R How to count occurrences of values across multiple columns of a data frame and save the columnwise counts from a particular value as a new row?

你离开我真会死。 提交于 2020-01-02 15:31:20
问题 I have a large data-frame (approx 1,000 rows and 30,000 columns) that looks like this: chr pos sample1 sample2 sample3 sample 4 1 5050 1 NA 0 0.5 1 6300 1 0 0.5 1 1 7825 1 0 0.5 1 1 8200 0.5 0.5 0 1 where at a given "chr"&"pos" the value for a given sample can take the form of 0, 0.5, 1, or NA. I have a large number of queries to perform that will require subsetting and ordering the data frame based on summaries of the values for each sample. I would like to get a count of the number of

R How to count occurrences of values across multiple columns of a data frame and save the columnwise counts from a particular value as a new row?

泄露秘密 提交于 2020-01-02 15:29:04
问题 I have a large data-frame (approx 1,000 rows and 30,000 columns) that looks like this: chr pos sample1 sample2 sample3 sample 4 1 5050 1 NA 0 0.5 1 6300 1 0 0.5 1 1 7825 1 0 0.5 1 1 8200 0.5 0.5 0 1 where at a given "chr"&"pos" the value for a given sample can take the form of 0, 0.5, 1, or NA. I have a large number of queries to perform that will require subsetting and ordering the data frame based on summaries of the values for each sample. I would like to get a count of the number of

Occurrence of symbol A found anywhere in L. LISP

梦想与她 提交于 2019-12-24 06:10:15
问题 Here is my function (defun freq (symbol_A List_L) (cond ((atom (car List_L)) (cond ((eq (car List_L) symbol_A) t (+ 1 (freq symbol_A (cdr List_L)))) (t 0))) (T (freq symbol_A (cdr List_L)))) ) I am getting an error variable ATOM has no value. Here is what I am testing with (freq 'c '((a c) c e)) --> 2 (freq 'f '(((s) o ) d)) --> 0 (freq 'f '(((f) f) f f)) --> 4 Can not understand where is my error. I also tried this: (defun freq (a L) (cond ((null L) 0) ((equal a (car L)) (+ 1 (freq a (cdr L)

Python co-occurrence of two items in different lists

孤街醉人 提交于 2019-12-22 18:34:45
问题 I have a list of lists like : names = [['cat', 'fish'], ['cat'], ['fish', 'dog', 'cat'], ['cat', 'bird', 'fish'], ['fish', 'bird']] I want to count number of times that each pair of names mentioned together in the whole list and the output would be like: { ['cat', 'fish']: 3, ['cat', 'dog']: 1,['cat','bird']:1 ['fish','dog'] : 1, ['fish','bird']:2} I tried : from collections import Counter from collections import defaultdict co_occurences = defaultdict(Counter) for tags in names: for key in

How to fix segmentation fault 11 error? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-22 01:09:15
问题 This question already has an answer here : Definitive List of Common Reasons for Segmentation Faults (1 answer) Closed 2 years ago . I want the main returns the position of the occurrences of "mdl" in "dati". I set up the "schema" function to find the starting point of each occurrence, but when i run the program from the command line, it returns: Segmentation fault: 11 I don't know how to fix the problem. Here's the code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include

Split CSV to Multiple Files Containing a Set Number of Unique Field Values

蓝咒 提交于 2019-12-13 16:30:26
问题 As a beginner of awk I am able to split the data with unique value by awk -F, '{print >> $1".csv";close($1)}' myfile.csv But I would like to split a large CSV file based on additional condition which is the occurrences of unique values in a specific column. Specifically, with input 111,1,0,1 111,1,1,1 222,1,1,1 333,1,0,0 333,1,1,1 444,1,1,1 444,0,0,0 555,1,1,1 666,1,0,0 I would like the output files to be 111,1,0,1 111,1,1,1 222,1,1,1 333,1,0,0 333,1,1,1 and 444,1,1,1 444,1,0,1 555,1,1,1 666

extract arabic letter from sentence or word

时光总嘲笑我的痴心妄想 提交于 2019-12-13 07:07:11
问题 i am developing a small program in vb6 that will work with an Arabic document, i want to count how many occurrence each Arabic letter appears in the document basic arabic characters ا أ إ آ ى ؤ ئ ء ب ت ة ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه example sentence البيت الكسز اللتيل الزجاج الست.‏ i don't know arabic or even know how to read it. if vb6 won't work, i can use vb.net 回答1: It'll be much easier to use VB.Net. VB6 has patchy support for Unicode. In VB6, you'd probably need to

Visualisation of missing-data occurrence frequency by using seaborn

柔情痞子 提交于 2019-12-13 04:17:14
问题 I'd like to create a 24x20 matrix(8 sections each has 60 cells or 6x10) for visualization of frequency of missing-data occurrence through cycles (=each 480-values ) in dataset via panda dataframe and plot it for each columns 'A' , 'B' , 'C' . So far I could map the create csv files and mapped the values in right way in matrix and plot it via sns.heatmap(df.isnull()) after changed the missing-data ( nan & inf ) into 0 or something like 0.01234 which has the least influence on data and in the