New to Python - 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: New to Python (/thread-28704.html) |
New to Python - jdc4429 - Jul-30-2020 Hello everyone, New to python and I'm sure this is not probably that hard but I have not found a way to do this in my searching. Ways I have found that I think might work are giving me errors. while 1 == 1: tic = time.time() prices = client.get_all_tickers() df = pd.DataFrame(prices) dn = df.to_numpy print(dn) tic2 = time.time() - tic print("sync call spend:", tic2) time.sleep(2 - tic2)I simply would like to create 2 variables (1 for each column) to store the values so I can work with them using the dn[1,1] type format to pull each value. Current output show... [893 rows x 2 columns]> sync call spend: 0.20111417770385742 <bound method DataFrame.to_numpy of symbol price 0 ETHBTC 0.03039100 1 LTCBTC 0.00516300 2 BNBBTC 0.00179920 3 NEOBTC 0.00106300 4 QTUMETH 0.00708300 .. ... ... 888 ZRXBUSD 0.39120000 889 DCRUSDT 15.50600000 890 STORJUSDT 0.19190000 891 XRPBKRW 283.57000000 892 ADABKRW 166.58000000 So again, I would like to be able to grab each value in each column in order to work with them. Thanks in advance for any help. Jeff RE: New to Python - jdc4429 - Jul-31-2020 Figured it out... dn = df.to_numpy(dtype=str) Had to change the dtype to string to prevent the error. sym= dn[line,0] price = dn[line,1] Now read properly. |