Skip to content

Tag: for-loop

globas and exec in python

I have written code, to create variable and assign values using for loop. but I am getting result as None but even I tried to change the code with below modification, still getting the same Can some one help me to get the proper answer for this. Note: even I used exec function in the place of name (ex: exec(f…

Substract two row values in dataframe python

Currently I have a sort of dataframe where I want to substract value from current row from the previous one. example: df = pd.Datafame([1,4,3,5,6],columns = [“time”)]) left 1 4 3 5 6 I want to iterate over these rows and store it in a list. So the list will get like this [-3,1,-2,-1]. So far I hav…

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