I'm working with arrays of length 1,000-10,000 elements, which all have the same length.
I need to return an array (called "points" in the sample code below) which contains a dictionary in each element of the array.
I have been looking for similar methods to the .loc method that can be used to create a rule for a column in a pandas data frame, but still haven't found a solution that doesn't involve iteratively appending the array I need to return.
Solutions greatly appreciated!
Current Code:
times = [000000001,000034000,...]
highs = [2,1,...]
lows = [-2,-3,...]
points = []
for i in range(0, len(times)):
points.append({"time": times[i], "low": lows[i], "high": highs[i]})
Solutions Suggested by Comments:
import pandas as pd
df = pd.DataFrame({"time": times,"low":lows,"high":highs})
which looks like:
Time High Low
0 100000001 1 -1
1 100000002 3 -4
2 100000003 4 -5
SE Posts Already Consulted:
Iteratively appending ndarray arrays using numpy in Python