Python Forum

Full Version: Populating an array dynamically
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Pandas. It has something called a Dataframe that works very well with columnar data.