'Iterating datetime field in a numpy array
I have a numpy array that looks like below. I wanted to pull out the data day by day and run a function on that. I tried doing it brute force (code snippet below) but that does not quite work either. I'm sure there is a function of some sort that will just pull out the parts of array that correspond to particular day and pass that subset to my function:
while i < len(stoch_osc):
print('value of i is: ', i, ' Valuate of i+delta is: ', i + delta)
print(stoch_osc[i:i + delta, ])
some_function(stoch_osc[i:i + delta, ])
i = i + delta
stoch_osc is an array that looks like this (timestamp in datetime
followed by a bunch of values). I get below output by doing print(stoch_osc):
[[Timestamp('2021-10-01 00:32:00') 4276.0 4276.0 ... 4275.25 83 64.28]
[Timestamp('2021-10-01 00:33:00') 4275.5 4276.25 ... 4276.25 105 78.57]
[Timestamp('2021-10-01 00:34:00') 4276.25 4276.75 ... 4275.5 10167.85]
[Timestamp('2021-10-04 01:31:00') 4331.0 4333.0 ... 4332.25 582 71.21]]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
