In the previous article, we have used the Blockchain API to display the Bitcoin vs world major currencies exchange rate in our application. In this article, we will use the Pandas Data Frame object to create a beautiful table for our displaying data. I have already introduced the Pandas Data Frame object before in the previous chapter, therefore, I won’t go through it again in this post. Let us go straight to the business.

We will not use the sell buy string to display the currency data from Blockchain as before but we will directly construct the data frame object to display the related data.

BTC vs World Currencies table

The index of this data frame table will be the world currencies symbol and the column will be the bitcoin symbol.

Import Pandas module.

import pandas as pd

Construct the data frame object within the get exchange rate function.

# print the 15 min price for every bitcoin/currency
    currency_exchange_rate = []
    currency_index = []

    for k in ticker:
        #sell_buy += "BTC:" + str(k) + " " + str(ticker[k].p15min) + "\n"

    # construct the pandas data frame object
    d = {'BTC': currency_exchange_rate}
    df = pd.DataFrame(data=d, index=currency_index)

    text_widget.delete('1.0', END)  # clear all those previous text first
    text_widget.insert(INSERT, s.get())  # populate the text widget with new exchange rate data

We have commented out the sell buy string because we will use the data frame object to display the market data instead.

I have started a new python channel, come and join in the discussion through this link.

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *