Categories
Mastering Development

How to count number of observations that were negative before receiving a positive result

I am working with some clinical data and I would like to count the number of tests someone had that were "Not Detected" before they had a "Detected" result and exclude anyone that never had a "Detected" result. ID <- c(1,1,2,2,3,3,3,4) Specimen_Type <- c("NP", "NP", "Throat", "Throat", "NP", "Throat", "Throat", "NP") RESULT_VAL <- c("Not Detected", […]

Categories
Database Development

Row numbering difference between mariadb and mysql

I’ve recently updated my server into a docker setup and switched from mysql to mariadb. No I’ve run into an issue with different behavior between Mysql 5.7 on my local machine and MariaDB 10.5.6 on the server. The problem is a different result for a query which should return row numbers. I’ll explain using a […]

Categories
Ask Games RPG Games

Chances of specific sequence in X amount of dice?

So after fumbling around in AnyDice for awhile, I’m struggling to find a solution. Here’s what I’m looking for: What are the chances of rolling a specific number that matches a specific sequence in order in multiple dice? For example, in Xd6, I’m trying to figure out what that chances of rolling a 5+, THEN […]

Categories
Mastering Development

Find most frequently numbers in Python with Pandas from CSV

I have 5 rows with 10 numbers from 1 to 100 | | A | B | C | D | E | F | G | H | I | J | +—+—+—+—-+—-+—-+—-+—-+—-+—-+—-+ | 1 | 1 | 3 | 4 | 8 | 12 | 35 | 41 | 70 | 79 | […]

Categories
Mastering Development

Python iterating through dictionary

I am trying to iterate through a dictionary and I’m not sure how to update while looping through. What I’m trying to do (Simulating LFU cache): Requests are taken, Iterate through each requests one by one and count the frequency of each using dictionary. If the dictionary holds more than 8 keys remove the lowest […]

Categories
Mastering Development

Getting the name of a specific column of df within a list

Example Data: df1 <- as.data.frame(rbind(c(1,2,3), c(1, NA, 4), c(NA, NA, NA), c(4,6,7), c(4, 8, NA))) df2 <- as.data.frame(rbind(c(1,2,3), c(1, NA, 4), c(4,6,7), c(NA, NA, NA), c(4, 8, NA))) dfList <- list(df1,df2) colnames <- c("A","B","C") dfList[[1]] # V1 V2 V3 # 1 1 2 3 # 2 1 NA 4 # 3 NA NA NA # […]

Categories
Mastering Development

Is there a more concise way to conditionally loop over rows in a dataframe?

I have a simple dataframe and would like to apply a function to a particular column based on the status of another column. myDF = pd.DataFrame({‘trial’: [‘A’,’B’,’A’,’B’,’A’,’B’], ‘score’: [1,2,3,4,5,6]}) I would like to multiply each observation in the score column by 10, but only if the trial name is ‘A’. If it is ‘B’, I […]

Categories
Mastering Development

Is this prediction acceptable or not?

I have started a course on machine learning, and in one of the lessons, the teacher said that is not necessary to do it when using Multiple linear regression. My problem appears when I was doing an exercise, where the data set is this: 2104,3,399900 1600,3,329900 2400,3,369000 1416,2,232000 3000,4,539900 1985,4,299900 1534,3,314900 1427,3,198999 1380,3,212000 1494,3,242500 1940,4,239999 […]

Categories
Mastering Development

Can I “pair” traces in Shiny plot_ly so that two traces appear/disappear when clicking on legend?

I’m creating an app where I have regional data on a few vars. The app allows you to select via a selectInput the region the user wants to visualize. For comparison/information purposes, I’d like the user to visualize both the region selected as well as the national average in the plot_ly. However, I’d like the […]

Categories
Mastering Development

spark scala column to counter of column unique values

How can I correctly get column values as Map(k->v) where k is unique value and v is occurence count? I do it within groupby. val getMapUDF = udf((arr: Array[Long]) => {arr.groupBy(identity).map{ case (x,y) => x -> y.size}}) df .withWatermark("time", "30 seconds") .groupBy(window(col("time"), "1 minutes").alias("someTime"), col("foo"), col("bar")) .agg(count("*").alias("rowCount"), collect_list(col("aaa")).alias("aaaList")) .withColumn("qtypes", getMapUDF(col("foobar"))) EDIT: input +———–+——————-+ | foo […]