Please, I have a dataframe that is listed in ascending order. My goal is to average similar numbers (numbers that are within 10% of each other in ‘both directions’) and concate their ‘Bell’ name together. For example, the image shows the input and output dataframe. I tried coding it but I stuck on how to progress. Answer Assuming you really
Tag: iteration
Fastest way to get dot product of a matrix and each point in the given array
I have an array Nx3 of N points, each one has X, Y and Z coordinate. I need to rotate each point, so i have the rotation matrix 3×3. To do this, i need to get dot product of the rotation matrix and each point. The problem is the array of points is quite massive (~1_000_000x3) and therefore it takes
Iterating through a column and mapping values
Here is what I am trying to do. I want to substitute the values of this data frame. For example. Bernard to be substituted as 1, and then Drake as 2 and so on and so forth. How to iterate through the column to write a function that can do the following. Answer The function already exists – pd.factorize. It
How to run my Python code for every Excel file contained in a folder?
I have a folder named with a certain acronym, and inside this folder you can find a certain number of Excel files. The folder’s name indicates the name of the apartment (for ex. UDC06_45) and, inside this folder, all of the Excel files’ name are composed by: the name of the apartment, followed by the name of the appliance that
Append data in Excel using Python Selenium Openpyxl
I have a sheet with 5 registration numbers, which are successfully being entered into the webpage search, and the code runs without errors while iterating using a ‘For’ statement for each row in the ‘A’ column (Col=0). I am now trying to append the colour returned by the code into the corresponding row in the ‘B’ column (col=1) The code
Iterating through list of lists of lists
I am trying to iterate through a 3-D list in python(not numpy but I am willing to convert to a numpy array if this makes it easier) in such a way that from a list like this: I can get the output I can’t figure out how to make it iterate like this… My code: I’ve tried different things but
Iteratively apply a function to an array
I want to create an array that contains g^0, g^1, g^2…. up to g^100 but all to mod50 (apologies if anyone knows how to format this so the powers are properly aligned I need a bit of help!) In my case g = 23, so I would want an array that looks like: I’ve included all my (incorrect) code at
Animation issue in Python
I want the green rectangle to not disappear as it moves from one value to another in matrix b. For example, the rectangle is around 0.24671953. Then the rectangle stays on this value. Then another rectangle appears onto the next value which is 0.25959473. Then another rectangle appears on 0.41092171, with the previous two rectangles not disappearing. Answer It looks
Numpy array: iterate through column and change value based on the current value and the next value
I have an array like this: This is an extension of a recent question that I asked elsewhere here. I have a numpy array like this: In the third column, I want the value to be replaced with 10001 if the next one along is 101 AND if the current one is 6. which would result in an array like
Trying to show all numbers lower than the average in another list
For school we have to make a code which shows the average of a certain list into another list but for some reason my list which should show the smaller numbers is empty, I don’t know if it is possible but I tried using an extra variable which counts +1 to itself help is appreciated in advance. Answer 2 things: