Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Python
#1
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
Reply
#2
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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020