Categories
Mastering Development

How to use a cut in prolog to find the number of daughters?

Exercise: Observe the family structure below where each person has a gender specification as their third parameter (m = male, f = female). Use a cut to write the predicate numDaughters(L, Count) in such a way that family(Husband, Wife, Kids), numDaughters([Husband, Wife|Kids],X) lists each family in the database and the number of daughters in each […]

Categories
Database Development

Concatenating only desirable values with LISTAGG

In the Oracle DB there is a table with data "YEARS", see a table/image below +—–+———–+——————+ | FID | I0 | BJA | +—–+———–+——————+ | 1 | 0 | 1949 | | 2 | 0 | 1996 | | 3 | 0 | 1970 | | 4 | 1 | 1871 | | 4 | […]

Categories
Mastering Development

Need help parsing data from .csv file C

I have the following .csv file containing information about the song, artist, release year(if specifed) and number of listens: Look What The Cat Dragged In,Poison,,Look What The Cat Dragged In by Poison,1,0,1,0 Nothin’ But A Good Time,Poison,1988,Nothin’ But A Good Time by Poison,1,1,21,21 Something To Believe In,Poison,1990,Something To Believe In by Poison,1,1,1,1 Talk Dirty To […]

Categories
Mastering Development

how to show the results of two different functions, working with lists and sapply? or for loop?

For each unique id I’m taking the first 3 rows (studies) to predict the remaining studies in that id. I was able to write the code but I couldn’t show the results. id <- c(1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3) year <- c(1978, […]

Categories
Mastering Development

How to identify the virus or process

I have noted unauthorized access to my router (default gateway) from my PC (Catalina iMac). I am investigating this because we have several Mac PCs that are having the same behavior. I would like to identify the virus or process that is causing this unauthorized access and remove it. We scanned our PC with Virus […]

Categories
Mastering Development

Sort data by bins using groupby

I want to show the most frequent genre (df.listed_in) of program in each decade (df.release_year) I can show the most frequent by year using the following formula df.groupby(‘release_year’)[‘listed_in’].apply(lambda x: x.mode().iloc[0]) that shows the following result: To show the most frequent genre by decade I tried the following formula: bins = [1925,1950,1960,1970,1990,2000,2010,2020] groups = df.groupby([‘listed_in’, pd.cut(df.release_year, […]

Categories
Mastering Development

coerce colon operator or dash from character to vector inside cell in r

I have some df cells that contain lists of years. Most are years typed out and separated by commas: "1990, 1992, 2001", but some use colon operators: "1990:2000". Even some use a combination: "1990, 1995:1999, 2001" Is there a way in R to convert these different kinds of strings into consistent comma separated values still […]

Categories
Mastering Development

Arranging rows in R so that year column is in a custom order, and other columns with identical entries are grouped

I have tried the solution for Arranging rows in custom order using dplyr but still can’t figure it out for my dataframe. I have a dataframe USA_tech with 62,000 entries that looks like this: region supplysector subsector technology year coefficient tech_change AK agriculture agriculture agriculture 1975 .01 NA AL agriculture agriculture agriculture 1975 .22 NA […]

Categories
Mastering Development

avoid overwrite values using time series and forecast future value in loop R

I am running loop in R for time series (5y point) data. I want to get a result for new data (rata) using a formula (include initial and prior values). But, I get something weird. Gere is my code: n=7 set.seed(1) #data ta=c(1950,1955,1960,1965,1970,1975,1980) ra=c(1.7,1.3,-2.7,-2.4,3.3,5.7,1.7) rata=matrix(c(ta,ra),nrow=7) #rata ## initials a=runif(n,1,10) b=runif(n,0,10) c=runif(n,-100,100) d=runif(n,0,100) #priors p=runif(n,0,1) q=rnorm(n,c,d) […]

Categories
Mastering Development

Understanding the group_by behavior in R

I’ve been trying to understand what exactly group_by returns. I believe it must be a vector for each unique group_by combination that exists. Consider the following: data<-data.frame(Names = c(“odyssey”, “camry”, “odyssey”, “camry”), year = c(1990, 1990, 1992, 1994), sales = c(200, 400, 1000, 4000)) If we ask for the percent sales as given below, we […]