if statement and for loop I am stuck with the following code, I have a column in which I want to divide by 2 if the number is above 10 and run this for all the rows. I have tried this code but it gives the error of the series is ambiguous: I suppose that I need a for loop
Tag: for-loop
Bash for loop containing python script
New here! I’m trying to loop a python script in bash that gets stats from fastq files. I want it to loop through all the fastq files in a directory and save the outputs in a text file. Ideally don’t want to edit the python script This is the script that works when I’m not looping it: This is the
how to write a conditional for loop in DAX?
I’m using PowerBI to create a dashboard that summarizes data from a train movements simulation. (I’m a psychologist with some basic understanding of python and currently learning DAX.) Here is some background: I use [index] to maintain the order of the rows [Notification] is a column that contains text [Train Nr] is a column that contains the ID of the
generated empty [i] in for loop
I want to create an empty set up to the value n entered by the user and assign the values in the for loop into this set. But for this, it is necessary to create as many for loops as the user inputs, it is not possible to do this. How can I do it? The code below works correctly,
Pandas appending dictionary values with iterrows row values
I have a dict of city names, each having an empty list as a value. I am trying to use df.iterrows() to append corresponding names to each dict key(city): Can somebody explain why the code above appends all possible ‘fullname’ values to each dict’s key instead of appending them to their respective city keys? I.e. instead of getting the result
What’s the cleanest way of counting the iteration of a queryset loop?
I need to loop through a queryset and put the objects into a dictionary along with the sequence number, i, in which they appear in the queryset. However a Python for loop doesn’t seem to provide a sequence number. Therefore I’ve had to create my own variable i and increment it with each loop. I’ve done something similar to this,
Python – Iterate through multiple dataframes and append data to a new dataframe
I have 3 pandas dataframes. I would like to append one row from each in each iteration to an existing dataframe. Example shown below: Dummy code: Please could someone point me in the right direction? Answer Concatenate them, using the keys argument to associate an index with rows from each original dataframe, then swap the index levels and sort the
how to match two lists that contain some matching strings?
I have two list such as. First list contains some additional string in the elements but I want to find the match with or without converting it to integer from the second list. output req: Tried: Answer If you only want to compare the number part you have to do some conversion. Start with l2 is now [1, 4]. Now
Compare all elements of a list
To illustrate my problem, imagine I have a list and I want to compare each element with the next one to check if they are the same value. The problem is that when I try to access the last element of the list and compare it with “the next one”, that one is out of range, so I would get
For loop with lot of different Urls
totally novice in python, after many youtube videos and tutorial i’m trying to scrape basketball starting lineups from flashscore. Here’s an example of a link: https://www.flashscore.it/partita/6PN3pAhq/#informazioni-partita/formazioni As you can see in the middle there’s a code (6PN3pAhq) that corresponds to a particular match: every match has a different one, i scraped all the results (144 matches at the moment) and