Convert to modefull into data frame and extract only certain values

joematthew89
Hi,
I am still learning, i would highly appreciate it someone could help or point me in the right direction or help fix what i am doing wrong. For a list of instrument tokens i am trying to extract the total buy and sell quantities . When i tried, i got multiple errors like TypeError: 'bool' object is not iterable and Data is not a list.
I am unable to flatten the data and extract it. I tried to follow the guide in this page "https://kite.trade/forum/discussion/7061/tick-data-to-python-pandas" as well. However, i got an error "raise NotImplementedError"


kws.on_ticks = on_ticks
kws.connect(threaded=True)
while not kws.is_connected():
time.sleep(1)
print("WebSocket : Connected")
kws.subscribe([11510530, 11517954])
data = kws.set_mode(kws.MODE_FULL, [11510530, 11517954])
df = pd.DataFrame(data)
extracted_data = [
{
'instrument_token': item.get('instrument_token'),
'total_buy_quantity': item.get('total_buy_quantity'),
'total_sell_quantity': item.get('total_sell_quantity')
}
for item in data if isinstance(item, dict)
]

print(extracted_data)

Thanks,
Joe
Sign In or Register to comment.