I want to get the single value out of the object output which is "bitcoin" in my case but when i run the code, it only returns me an object pair value.
import pandas as pd
from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI()
dflist=pd.DataFrame(cg.get_coins_list())
dflist["id"].loc[dflist['symbol'] == "btc"]
I tried this following code below but it only return me "true"
dflist["id"].loc[dflist['symbol'] == "btc"].all()
CodePudding user response:
You could return a view from the dataframe and then just choose an index if you know there's only one output.
btc = dflist[dflist['symbol'] == "btc"]
btc.iloc[0]
CodePudding user response:
Use methods mentioned in the documentation
cg.get_price(ids='bitcoin', vs_currencies='usd')
Output
{'bitcoin': {'usd': 3462.04}}