A Gentle Introduction to Python’s Time Module

Having looked at the Python date and datetime modules in previous articles, today we’ll take a closer look at the time module and understand how to extract, input, and work with times in our coding. First, I’ll recap on computer time and introduce the time object we’ll be using with the functions we introduce later … Read more

Are Energy Costs and CapEx Invested in Bitcoin Worth It?

Bitcoin capital expenditure and energy overhead are often criticized to be unsustainably high. But are they worth it in relation to the value provided by the Bitcoin network? TLDR; Capex and energy costs are estimated using the USD value of the transaction fees paid by the Bitcoin traders. The value of the Bitcoin monetary system … Read more

How to Get All Transactions for a BTC Address in Python?

Problem Formulation Given a single Bitcoin address in the form of a stream of characters such as the address of the first “Genesis” block ever created on the Bitcoin blockchain: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX How to get all transactions for this BTC address in a Python script? Solution To get all transactions of a given Bitcoin address, import … Read more

How to Get Binance API Prices in Python at a Precise Time?

Problem Formulation Say, you want to get the current price of a cryptocurrency using Python’s inofficial binance API. How do you do this for a precise point in time? Step 1: Install Python Binance with pip If you haven’t already, install the Python Binance API using the pip package manager. Run pip install python-binance in … Read more

How to Get a Function Name as a String in Python?

Problem Formulation Given a function object assigned to a name. How to get the name of the function as a string? For example, consider the following function your_function. How to get the name “your_function” from this? Your desired value of the result stored in string_name is the string “your_function”. Method 1: Use the __name__ Attribute … Read more

How To Plot SKLearn Confusion Matrix With Labels?

Summary: The best way to plot a Confusion Matrix with labels, is to use the ConfusionMatrixDisplay object from the sklearn.metrics module. Another simple and elegant way is to use the seaborn.heatmap() function. Note: All the solutions provided below have been verified using Python 3.9.0b5. Problem Formulation Imagine the following lists of Actual and Predicted values … Read more