I have the following list: From dataframe column I want to find texts that have the words of the list in order to generate a new column that can print these words along with the next word, for example, in a column cell there is the following text WOULD NOT PRIME CORRECTLY DURING VIRECTOMY., I want a new column that
Tag: loops
python question about loops comparing string to string
I am trying to emulate a circumstance where i send information and only get a true or false as a return. So i can check each character and if it is true, that means that character is in the string. I would know there would be a position 0 to some number x. I would receive a true result and
converting a tree array to a specific string (chemical formulas) (py)
I have a specific kind of array which looks often like this: and I want to convert it to something like Ca3(PO4)2. Could someone help me? I tried a lot of techniques, but the code gets always really messy. I do not know what am i doing wrong. I use python by the way. P.S.: if anything’s wrong, tell me
How to deny letters and symbols in loops
I only want my code to accept numbers between 1 to 9. I tried try except, logical operators, isdigit, but I just can’t do it. Answer It look like you’re trying to print out the prompt based on the user input, and you want to make sure that it’s not higher the 9 and lower than 1. You need to
Sum of the column values if the rows meet the conditions
I am trying to calculate the sum of sales for stores in the same neighborhood based on their geographic coordinates. I have sample data: ID SALE X Y X_MIN Y_MIN X_MAX Y_MAX 1 100 23 44 22 43 24 45 2 120 22 45 21 44 23 46 3 110 21 41 20 40 22 42 4 95 24 46
Python – Iterate through list of website and scrape data – failing at requests.get
I have a list of items that I scraped from Github. This is sitting in df_actionname [‘ActionName’]. Each [‘ActionName’] can then be converted into a [‘Weblink’] to create a website link. I am trying to loop through each weblink and scrape data from it. My code: My code is failing at ” detailpage= requests.get(URL) ” The error message I am
Python count up by 5 after each iteration in for loop
I am trying to open a csv file in python and read the rows into a list. The list is then sent to a function where I want to add 5 to the value of x after each iteration with the value of d going up by 10 after every 10th iteration. d I have working but can’t quite figure
Change value every nth iteration python
How can I change a value inside a loop every 10th iteration? Say I have a list with 30 properties I would like to change the value of x by a factor of 10 every 10th time. Desired outcome ** Answer Modulo is a nice way of doing that: Edit: you should probably initialize x outside the loop.
Looping through HTML & following links
I am writing a code that is supposed to open a url, identify the 3rd link and repeat this process 3 times (each time with the new url). I wrote a loop (below), but it seems to each time sart over with the original url. Can someone help me fix my code? Answer You need to define the empty list
Increasing performance for search pandas df, Count occurrences of starting string grouped by unique identifier
Current dataframe is as follows: Expected Output: Question: How do I get the counts of the ‘starting string’, only when uniqueID is occurring for the first time with increased performance. Thus far, I’m doing with a simple for loop of the data and checking with if/else statements. But this is incredibly slow with a large dataframe. I’m curious if there