iteration

Iterate through chunks of a pandas Dataframe

Iterate through chunks of a pandas Dataframe Question: I have a pandas.DataFrame that looks like the following: Week Monday Tuesday Wednesday Thursday Friday City A 100 300 x z w City B 200 400 y q p None None None None None None Week Monday Tuesday Wednesday Thursday Friday City A 150 320 a c …

Total answers: 2

Time Complexity of this program solving the coin change problem

Time Complexity of this program solving the coin change problem Question: I have created a program shown below, and I am confused as to how to figure out its time complexity. Is it O(ntarget/min(coins)) because a for loop is created each time the function is called, and the function is called target/min(coins) times? The program …

Total answers: 1

Iterating through a dictionary to get next values from previous values

Iterating through a dictionary to get next values from previous values Question: I have this sample dataset {‘data1’:200, ‘data2’:500} I want to iterate this data in a range of 25, such that each iteration would give me the previous value * (1+0.05) within the iteration. In this case the output of range of 2 would …

Total answers: 4

Trying to understand the difference in what matches and the resulting output for findall vs finditer

Trying to understand the difference in what matches and the resulting output for findall vs finditer Question: Using findall: import re target_string = "please sir, that’s obviously a clip-on." result = re.findall(r"[a-z]+(‘[a-z])?[a-z]*", target_string) print(result) # result: [”, ”, "’s", ”, ”, ”, ”] Using finditer: import re target_string ="please sir, that’s obviously a clip-on." result …

Total answers: 1

Combinations of words and digits with specific order

Combinations of words and digits with specific order Question: I need all possible combinations of upper words and digits in this format digit-word-word-word . I tried this code : upper_a = [‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, …

Total answers: 2

Find element in list n times Python

Find element in list n times Python Question: Given are a = [1, 4, 2, 5] b = [[[0, 1]], [[0, 2]], [[0, 3]], [[0, 4]], [[0, 5]], [[0, 6]], [[0, 2]], [[0, 3]], [[0, 4]], [[0, 5]], [[0, 4]], [[0, 5]], [[0, 6]], [[0, 4]], [[0, 2]], [[0, 2]], [[0, 4]], [[0, 4]], [[0, …

Total answers: 3

Select certain elements from a list with a loop and condition

Select certain elements from a list with a loop and condition Question: I have a list similar to this one below, but much larger. mylist = [‘ 12345678912 ST’, ‘ Halterung für Fortlüfterhaube’, ‘ Material/Werkstoff: Metall-Lackiert’, ‘ **Beginn Zeichnung**’, ‘ 98765432164 ST’, ‘ Klappe, komplett’, ‘ **Beginn Zeichnung**’, ‘ 74563254671 ST’, ‘ Sieb Außen-Dm 145 …

Total answers: 2