Python Forum
Populating an array dynamically - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Populating an array dynamically (/thread-37245.html)



Populating an array dynamically - zxcv101 - May-17-2022

Hi guys - am new to Python, so if my questions seem basic, pls bear with me.

I have a script which returns rows of data in this format :

20220517 09:10:00 147
20220517 09:20:00 147
20220517 09:30:00 148
20220517 09:40:00 148
20220517 09:50:00 145

I get this output with the following bit of code :

class IBapi(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)

def historicalData(self, reqId, bar):
print(f'{bar.date} {round(bar.close)}')


I want to store this data in an array (3 columns and not sure how many rows there will be).
FYI, the first column is the date (2022-May-17), the second is the time, and the third is the price.

What is the best way to do this in Python?

Cheers


RE: Populating an array dynamically - deanhystad - May-17-2022

Pandas. It has something called a Dataframe that works very well with columnar data.