Reputation: 21
I have been extracting information from the coingecko API via pycoingecko
ren_daily_price=cg.get_coin_market_chart_range_by_id(id='republic-protocol',vs_currency='usd',from_timestamp=1585267200,to_timestamp=1616457600)
it gives me a object type dict
type(ren_daily_price)
dict
I am converting into a dataframe with this command and i get the below:
df=DataFrame.from_dict(ren_daily_price)
df
you can see the unix number is representing the same date for each row. How can i extract the date to act as index then i have the columns for prices, market_caps and Volume?
Date | Prices | market_caps | Volume |
---|---|---|---|
1585267200000 | 0.0456998 | 39721342.05347 | 2548106.9 |
Upvotes: 2
Views: 143
Reputation: 9619
You could try this to get the second item from the lists for all cells:
df = df.applymap(lambda x: x[1])
Upvotes: 1