Using Python to Load Bitcoin Data

This will be a short post to show just HOW EASY it is to use Python and the Pandas' library to load our CSV historical data files that we offer. For our example, we will use the Binance exchange data set for Bitcoin found here: https://www.cryptodatadownload.com/cdd/Binance_BTCUSDT_d.csv

                    1   # The first thing we want to do is import the Pandas library and set the filepath to our data file
                    2   import pandas as pd
                    3   filepath = "https://www.cryptodatadownload.com/cdd/Binance_BTCUSDT_d.csv"
                    5   import ssl  # we need to import this library and tweak one setting due to fact we use HTTPS certificate(s)
                    6   ssl._create_default_https_context = ssl._create_unverified_context
                    8   # Now we want to create a dataframe and use Pandas' to_csv function to read in our file
                    9   df = pd.read_csv(filepath, skiprows=1)  # we use skiprows parameter because first row contains our web address
                    11  # Now that we have loaded our data into the dataframe, we can preview it using the print & .head() function
                    12  print(df.head(15))  # print first 15 lines of dataframe


Sample results from the above code!

Use the Pandas library to easily load our Python data!


Follow Us
Drop us your email to receive new risk postings