Finding percentage of users with certain conditions

Advertisements Using MySQL, I need to find the percentage of users with >= 30 AverageActiveMinutes AND the percentage of users with < 30 AverageActiveMinutes from a table with the following structure: Id AverageActiveMinutes 1503960366 37.92 1644430081 2.50 1844505072 0.00 3977333714 19.82 5553957443 97.88 7086361926 47.46 8792009665 1.67 I am looking for an output with two… Read More Finding percentage of users with certain conditions

PYTHON – Compare two lists and return match percentage while considering order

Advertisements I’m trying to write a program in Python that compares a list of inputs with an existing list then returns the match percentage between the two lists, as if it was verifying answers to an exam. print (‘Please answer the 20 questions with a, b, c, d or e\n’) correct = (‘a’,’c’,’d’,’d’,’e’,’b’,’c’,’c’,’a’,’b’,’d’,’c’,’b’,’e’,’c’,’b’,’a’,’e’,’b’,’c’) #correct answers… Read More PYTHON – Compare two lists and return match percentage while considering order

Regex expression that requires a user to input a number as a %

Advertisements Can’t figure out how to create a regex expression that requires the user to input a number as a % >Solution : It’s very simple, it looks like this: const val1 = “10”; const val2 = “10%”; const checkPercentage = val => /\d+%$/.test(val); console.log(checkPercentage(val1)); console.log(checkPercentage(val2)); \d+ represents between 1 digit and + %$ means… Read More Regex expression that requires a user to input a number as a %

calculate the percentage of times the highest value of a row corresponds in each variable

Advertisements I have a data frame in R as follows: set.seed(123) A <- as.data.frame(matrix(rnorm(20 * 5, mean = 0, sd = 1), 20, 5)) which results in: > A V1 V2 V3 V4 V5 1 -0.56047565 -1.06782371 -0.69470698 0.37963948 0.005764186 2 -0.23017749 -0.21797491 -0.20791728 -0.50232345 0.385280401 3 1.55870831 -1.02600445 -1.26539635 -0.33320738 -0.370660032 4 0.07050839 -0.72889123… Read More calculate the percentage of times the highest value of a row corresponds in each variable

I am trying to make a table with percentages after having used pivot.wider in R

Advertisements I am currently trying to make a table with percentages after having used the pivot.wider command on a variable. htrisk is the datafile and menopaus and invasive are variables. Using the following code: p_t <- htrisk %>% group_by(menopaus, invasive) %>% count(invasive, name = "n") %>% pivot_wider(names_from = invasive, values_from = n, values_fill = 0)… Read More I am trying to make a table with percentages after having used pivot.wider in R

Calculate percentage of dictionary values

Advertisements all_brands_scores = dict(sorted(all_brands_scores.items(), key=lambda item: item[1])) print(all_brands_scores ) output: {‘ADATA’: 0, ‘GIGABYTE’: 0, ‘CyberPowerPC’: 0, ‘Hyundai’: 0, ‘Thomson’: 0, ‘KANO’: 1, ‘Alienware’: 1, ‘Razer’: 1, ‘Google’: 1, ‘LG’: 2, ‘HP OMEN’: 5, ‘Acer’: 12, ‘Apple’: 13, ‘Microsoft’: 13, ‘MSI’: 17, ‘Samsung’: 18, ‘Dell’: 24, ‘ASUS’: 54, ‘Lenovo’: 71, ‘HP’: 104} I have this file(dic)… Read More Calculate percentage of dictionary values