Skip to content
Advertisement

Loop through a dataframe, using specific values for individual dates

I have a dataframe that looks like the below. I want to create a new column titled ‘Daily Change’ which will be the result of the first ‘Open’ price of each day divided by the ‘Open’ price for each 5 minute interval. Once the dates changes I need to the first open price of that day and so on. This is a sample and i want to be able to handle more than two days.

JavaScript

I tried the below but get a response stating that the truth value is ambiguous.

JavaScript

Advertisement

Answer

You can use resample_first to get the first opening value per day then broadcast the value along the rows:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement