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
Mastering Development

Merge more then 3 csv files in different JSON objects node-red

I have a main.csv file with several lines (for now we can assume 3 lines – first one with the titles and 2 with the data), each data line contains some data + reference to another csv file with other details. I want to read main.csv file line by line, get the file name from […]

Categories
Mastering Development

Pandas getting values splitted in variables

So, I’m trying to use pandas to go through a CSV line by line and split the value of every column into variables. csv = pandas.read_csv(‘file.csv’, sep = ‘;’, usecols = [‘ref’, ‘design’, ‘quant’]) I need to get the ref, design and quant values into 3 separated variables so I can process it, after that […]

Categories
Mastering Development

Cloud function – Convert txt file into csv file and populate bigquery table

I am trying to convert a txt. file into a csv. and populate a BigQuery table with all data through a Google Cloud function. I tried to apply the python script shared above but it didn’t work… My function is running properly but it doesn’t populate any data to BigQuery. My main.py function: import pandas […]

Categories
Mastering Development

Count frequency of itemsets in the given data frame

I have following data frame, data = pd.read_csv(‘sample.csv’, sep=’,’) I need to search the frequency of itemsets present in a set. For example: itemsets = {(143, 157), (143, 166), (175, 178), (175, 190)} This should search the frequency of each tuple in the data frame (Trying to implement Apriori’s algorithm). I’m particularly having trouble with […]

Categories
Mastering Development

R: unwanted character ” −” appearing when importing text files

I am working with the R programming language. I have a notepad txt file called "inflation.txt". The file has two columns (delimited with a "space") and looks something like this: 1950-1 0.0084490544865279 1950-2 −0.0050487986543660 1950-3 0.0038461526886055 1950-4 0.0214293914558992 1951-1 0.0232839389540449 1951-2 0.0299121323429455 1951-3 0.0379293285389640 1951-4 0.0212773984472849 I am trying to import this file into R. […]

Categories
Mastering Development

How to insert a text in the last row and in a specific column of an csv file using pandas?

I am trying to insert a text in the last row and in a specific column of a csv file, I already search on the internet but I don´t find any solution. In the example below I just want to add an email. Example: Name, Age, email Jake, 23, jake@gmail.com Camila, , Camila,outlook.com , , […]

Categories
Mastering Development

R ggplot a vertical line based on a condition, but after a facet_grid command?

I have this image that is the result of this ggplot command: causative_snp = filter(LOD_table, str_detect(`Causative SNP Chromosome: Calculation Method`, "Chr. 23")) %>% pull(`Causative SNP`) %>% extract(1) ggplot(data = LOD_table, mapping = aes(x = `Locus (Mb)`, y = `LOD Score`)) + facet_grid(`Test Type` ~ `Causative SNP Chromosome: Calculation Method`) + geom_vline(xintercept = causative_snp, color = […]

Categories
Ask Geographic Information System (GIS)

Cumulative sum of rasters with Python QGIS

I would like to perform a cumulative sum of rasters in QGIS. What I want to do is to have cumulate_0 = lambdajan as a first step of the sum, and then at every step of the ‘for loop’ making the sum of cumulate[i-1] + lambda[i]. I am not sure this is a right code, […]

Categories
Mastering Development

Is it possible to create a new folder and then export R data to this folder?

Initially, I have the following code path="M:/MainFiles/" Index="Columbus" write.csv(data,paste(paste(paste(path,Index, sep = ""), Sys.Date(), sep = "_" ), ".csv", sep = "")) This file is saved to "M:/MainFiles/Columbus_2021-01-21.csv" I want that the file is saved to "M:/MainFiles/2021-01-21/Columbus_2021-01-21.csv" , where 2021-01-21 is Sys.date(). As a result, every ay a new folder is created and the file is […]