frequency

Python library for playing fixed-frequency sound

断了今生、忘了曾经 提交于 2019-11-27 00:34:11
问题 I have a mosquito problem in my house. This wouldn't usually concern a programmers' community; However, I've seen some devices that claim to deter these nasty creatures by playing a 17Khz tone. I would like to do this using my laptop. One method would be creating an MP3 with a a single, fixed-frequency tone (This can easily done by audacity), opening it with a python library and playing it repeatedly. The second would be playing a sound using the computer built-in speaker. I'm looking for

Sql server function for displaying word frequency in a column

本秂侑毒 提交于 2019-11-26 21:41:39
问题 I have a table that lists a freet text input from a survey where enterents were allowed to enter their responses (regarding colours they would like to have in their wedding) I would like to write a sql function that gathers all the information from this column, and orders counts the frequency of each word, ordering the result set by this count. Response -------- Red and White green White and blue Blue Dark blue I would like the above table to be ordered as follows Response Frequency --------

Sort list by frequency

懵懂的女人 提交于 2019-11-26 20:56:54
Is there any way in Python, wherein I can sort a list by its frequency? For example, [1,2,3,4,3,3,3,6,7,1,1,9,3,2] the above list would be sorted in the order of the frequency of its values to create the following list, where the item with the greatest frequency is placed at the front: [3,3,3,3,3,1,1,1,2,2,4,6,7,9] I think this would be a good job for a collections.Counter : counts = collections.Counter(lst) new_list = sorted(lst, key=lambda x: -counts[x]) Alternatively, you could write the second line without a lambda: counts = collections.Counter(lst) new_list = sorted(lst, key=counts.get,

MySQL SELECT most frequent by group

自作多情 提交于 2019-11-26 14:37:07
问题 How do I get the most frequently occurring category for each tag in MySQL? Ideally, I would want to simulate an aggregate function that would calculate the mode of a column. SELECT t.tag , s.category FROM tags t LEFT JOIN stuff s USING (id) ORDER BY tag; +------------------+----------+ | tag | category | +------------------+----------+ | automotive | 8 | | ba | 8 | | bamboo | 8 | | bamboo | 8 | | bamboo | 8 | | bamboo | 8 | | bamboo | 8 | | bamboo | 10 | | bamboo | 8 | | bamboo | 9 | | bamboo

Python - Finding word frequencies of list of words in text file

拜拜、爱过 提交于 2019-11-26 14:08:28
问题 I am trying to speed up my project to count word frequencies. I have 360+ text files, and I need to get the total number of words and the number of times each word from another list of words appears. I know how to do this with a single text file. >>> import nltk >>> import os >>> os.chdir("C:\Users\Cameron\Desktop\PDF-to-txt") >>> filename="1976.03.txt" >>> textfile=open(filename,"r") >>> inputString=textfile.read() >>> word_list=re.split('\s+',file(filename).read().lower()) >>> print 'Words

How to find most common elements of a list?

爷,独闯天下 提交于 2019-11-26 12:23:00
Given the following list ['Jellicle', 'Cats', 'are', 'black', 'and', 'white,', 'Jellicle', 'Cats', 'are', 'rather', 'small;', 'Jellicle', 'Cats', 'are', 'merry', 'and', 'bright,', 'And', 'pleasant', 'to', 'hear', 'when', 'they', 'caterwaul.', 'Jellicle', 'Cats', 'have', 'cheerful', 'faces,', 'Jellicle', 'Cats', 'have', 'bright', 'black', 'eyes;', 'They', 'like', 'to', 'practise', 'their', 'airs', 'and', 'graces', 'And', 'wait', 'for', 'the', 'Jellicle', 'Moon', 'to', 'rise.', ''] I am trying to count how many times each word appears and display the top 3. However I am only looking to find the

Get highest frequency terms from Lucene index

萝らか妹 提交于 2019-11-26 11:38:34
问题 i need to extract terms with highest frequencies from several lucene indexes , to use them for some semantic analysis. So, I want to get maybe top 30 most occuring terms(still did not decide on threshold, i will analyze results) and their per-index counts. I am aware that I might lose some precision because of potentionally dropped duplicates, but for now, lets say i am ok with that. So for the proposed solutions, (needless to say maybe) speed is not important, since I would do static

Relative frequencies / proportions with dplyr

徘徊边缘 提交于 2019-11-26 11:02:35
Suppose I want to calculate the proportion of different values within each group. For example, using the mtcars data, how do I calculate the relative frequency of number of gears by am (automatic/manual) in one go with dplyr ? library(dplyr) data(mtcars) mtcars <- tbl_df(mtcars) # count frequency mtcars %>% group_by(am, gear) %>% summarise(n = n()) # am gear n # 0 3 15 # 0 4 4 # 1 4 8 # 1 5 5 What I would like to achieve: am gear n rel.freq 0 3 15 0.7894737 0 4 4 0.2105263 1 4 8 0.6153846 1 5 5 0.3846154 Try this: mtcars %>% group_by(am, gear) %>% summarise (n = n()) %>% mutate(freq = n / sum

Frequency table for a single variable

安稳与你 提交于 2019-11-26 10:21:34
问题 One last newbie pandas question for the day: How do I generate a table for a single Series? For example: my_series = pandas.Series([1,2,2,3,3,3]) pandas.magical_frequency_function( my_series ) >> { 1 : 1, 2 : 2, 3 : 3 } Lots of googling has led me to Series.describe() and pandas.crosstabs, but neither of these does quite what I need: one variable, counts by categories. Oh, and it\'d be nice if it worked for different data types: strings, ints, etc. 回答1: Maybe .value_counts() ? >>> import

Sort list by frequency

纵饮孤独 提交于 2019-11-26 09:54:25
问题 Is there any way in Python, wherein I can sort a list by its frequency? For example, [1,2,3,4,3,3,3,6,7,1,1,9,3,2] the above list would be sorted in the order of the frequency of its values to create the following list, where the item with the greatest frequency is placed at the front: [3,3,3,3,3,1,1,1,2,2,4,6,7,9] 回答1: I think this would be a good job for a collections.Counter : counts = collections.Counter(lst) new_list = sorted(lst, key=lambda x: -counts[x]) Alternatively, you could write