Python + pandas Dataframe

  dataframe, pandas, python

I’m really new to python, just playing around.
I have script that gets

——- received message ——- {"e":"24hrMiniTicker","E":1634212481158,"s":"ADAUSDT","c":"2.19200000","o":"2.12100000","h":"2.20000000","l":"2.10000000","v":"119875239.00000000","q":"259043876.72690000"}

from Binance stream. I’m able to print out this line in terminal and add it to an array, but I want to run this script in the background and have another script fill a pandas dataframe with that data.

1st Script:

import websocket
import numpy as np
import config
import pandas as pd
from binance.client import Client
from binance.enums import *
message_store = np.array
SYMBOL = "adausdt"
SOCKET = "wss://stream.binance.com:9443/ws/" + SYMBOL + "@miniTicker"
client = Client(config.API_KEY, config.API_SECRET, tld='us')
def on_open(ws):
    print('opened connection')


def on_close(ws):
    print('closed connection')


def on_message(ws, message):
    print('------- received message -------')
    print(message)
    message_store.append(message)
    #x = len(message_store)
    
    #print(x)

ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close, on_message=on_message)  
ws.run_forever()

2nd Script:

from getprice import message_store
import pandas as pd

dataframe = pd.DataFrame(data=message_store) 
print(dataframe)

ValueError: DataFrame constructor not properly called!

Any ideas how to do this the correct way?

Source: Python Questions

LEAVE A COMMENT