for-loop

use a pathname from a row in a dataframe in a for loop

风流意气都作罢 提交于 2020-05-30 07:56:56
问题 In an R script, I'd like to use use a pathname from a row in a dataframe in a for loop. For example, I'd like to get the directory size for each of the paths in column one in the following dataframe, by substituting "." in the code: sum(file.info(list.files(".", all.files = TRUE, recursive = TRUE))$size) with a value from the 'pathname' column. pathname size 1 F:/Asus/C_drive/WEPP/bitmap 0 2 F:/Asus/C_drive/WEPP/Data 0 3 F:/Asus/C_drive/WEPP/misc 0 4 F:/Asus/C_drive/WEPP/output 0 5 F:/Asus/C

How to use threading for multiply GET requests and compare

与世无争的帅哥 提交于 2020-05-30 05:14:50
问题 I have been trying to figure out how I can speed up and also get some knowledge with threading. I have been trying to create a function where I have put two GET requests. For each link I scrape some data and then I save it to a list which returns and then I will use that to compare to see if there has appeared new links in one of these links: """ def getScrapeLinks(self, siteURL): response = requests.get( siteURL, timeout=5 ) if response.ok: bs4 = soup(response.text, 'lxml') links = ['{}'

Delphi for loops and StringList Errors

▼魔方 西西 提交于 2020-05-30 03:58:51
问题 Ok guys, I've been trying to find out every possible mistake i'm making but I give up... I need help! What I'm writing is an app to manage rentals for my job and when the date is past, my app removes the name from 2 text files. I wrote 3 little functions(procedures) to make this work. Here: This one loads from dates.dat file and remove the line containing the name of the employee. procedure remDate(emp: String);/// Removes employee from date file var pos1, i: integer; dateList: TStringList;

accessing variable outside for loop

一笑奈何 提交于 2020-05-28 08:38:11
问题 how to access a string assigned some value in a for loop, outside the for loop i may provide you with the code for thy convenience for (Int32 i = 0; i < yourlist.Count; i++) { String str=(yourlist[i].ToString() + ","); } String str1 = (str).Substring(0, str.Length - 1); the error displayed is The name 'str' does not exist in the current context 回答1: The scope of the variable does not extend to outside the loop. If you want to access its value, you need to save it to another variable with a

accessing variable outside for loop

◇◆丶佛笑我妖孽 提交于 2020-05-28 08:36:57
问题 how to access a string assigned some value in a for loop, outside the for loop i may provide you with the code for thy convenience for (Int32 i = 0; i < yourlist.Count; i++) { String str=(yourlist[i].ToString() + ","); } String str1 = (str).Substring(0, str.Length - 1); the error displayed is The name 'str' does not exist in the current context 回答1: The scope of the variable does not extend to outside the loop. If you want to access its value, you need to save it to another variable with a

How to write a for loop which creates a model and has a function which references that same model

我的梦境 提交于 2020-05-26 09:09:25
问题 I am trying to run a post hoc analysis on an unbalanced two way anova using the anova_test funciton in the rstatix package. I need to run this post hoc test iteratively, as I have ~26 response (y) variables. My first step is to create models of all my y variables with relation to group and treatment . I have successfully managed to do this, creating a single list with 26 models: models <- map(data[,y1:y26], ~(lm(.x ~data$group*data$treatment))) Now comes the part I'm stuck on. Referring to

Iterating over a list in python using for-loop

一个人想着一个人 提交于 2020-05-24 04:55:05
问题 I have a question about iterating over a list in python. Let's say I have a list: row = ['1', '2', '3'] and want to convert its element to integers, so that: row = [1, 2, 3] . I know I can do it with list comprehension: row = [int(i) for i in row] or for-loop: for i in range(len(row)): row[i] = int(row[i]) My question concerns range(len(row)) part. Can someone answer in layman friendly way, why I can do something like this: for i in row: print(i) But I can't do this: for i in row: row[i] =

Creating a list of dictionaries with same keys?

╄→гoц情女王★ 提交于 2020-05-23 12:40:32
问题 I wanted to create a list that contains x amount of dictionaries all containing the same keys but with different values that's made in a for loop: Something like [{'name': Brenda, 'Age': 22, 'Sex': Female}, {'name': Jorda, 'Age': 32, 'Sex': Male}, {'name': Richard, 'Age': 54, 'Sex': Male}] My code is this: people = [] person = {} humans = gethumans() for human in humans: number_people, people_data = People.data() person['name'] = human.name person['age'] = human.age person['Sex'] = human.name

Creating a list of dictionaries with same keys?

只谈情不闲聊 提交于 2020-05-23 12:38:52
问题 I wanted to create a list that contains x amount of dictionaries all containing the same keys but with different values that's made in a for loop: Something like [{'name': Brenda, 'Age': 22, 'Sex': Female}, {'name': Jorda, 'Age': 32, 'Sex': Male}, {'name': Richard, 'Age': 54, 'Sex': Male}] My code is this: people = [] person = {} humans = gethumans() for human in humans: number_people, people_data = People.data() person['name'] = human.name person['age'] = human.age person['Sex'] = human.name

Run functions for each item on python list separately and append results retrieved from functions to a new list

最后都变了- 提交于 2020-05-17 07:42:54
问题 I'm looking for a way to pass separately each ID from 'email' list as a string to my functions and retrieve 'customerId' and save it to a 'newList' for each item on email list. my code: email = ['733867', '7338704'] newList = [] for x in email: def get_email_details(email, token, userId): headers = { 'accept': 'application/json', 'Content-Type': 'application/json', 'token': token, 'userId': userId} endpoint = 'request/' + email + '/details' return requests.get(url = HOST + endpoint, headers =