How to Find the Most Common Element in a NumPy Array

Problem Formulation and Solution Overview This article will show you how to find the most common element in a NumPy Array. To make it more interesting, we have the following running scenario: Carrie heard that Creative Prints is hiring a Python coder. They require the interviewee to answer several coding questions: one is to provide … Read more

Solidity by Example – Simple Open Auction (Explained)

This article continues on the series we started the last time: Solidity smart contract examples, which implement a simplified real-world process. Here, we’re walking through an example of a simple open auction. 🌍 Original Source Code: Solidity Docs We’ll first lay out the entire smart contract example without the comments for readability and development purposes. … Read more

Python – Finding the Most Common Element in a Column

Problem Formulation and Solution Overview This article will show you how to find the most common element in a Pandas Column. To make it more interesting, we have the following running scenario: You have been provided with a downloadable CSV file containing crime statistics for the San Diego area, including their respective NCIC Crime Codes. … Read more

(Solved) Python TypeError: ‘float’ object is not subscriptable

Problem Formulation Consider the following minimal example where a TypeError: ‘float’ object is not subscriptable occurs: This yields the following output: Solution Overview Python raises the TypeError: ‘float’ object is not subscriptable if you use indexing or slicing with the square bracket notation on a float variable that is not indexable. However, the float class … Read more

How to Convert a Float List to a String List in Python

The most Pythonic way to convert a list of floats fs to a list of strings is to use the one-liner fs = [str(x) for x in fs]. It iterates over all elements in the list fs using list comprehension and converts each list element x to a string value using the str(x) constructor. This … Read more

How to Find the Most Common Element in a Python String

Problem Formulation and Solution Overview This article will show you how to find the most common element in a Python string. To make it more interesting, we have the following running scenario: Sven, a Photographer, turned Python Coder, was called for an interview at Edge IT. Sven thought the interview was going well until he … Read more

[Fixed] Matplotlib: TypeError: ‘AxesSubplot’ object is not subscriptable

Problem Formulation Say, you’re me πŸ‘±β€β™‚οΈ five minutes ago, and you want to create a Matplotlib plot using the following (genius) code snippet: If you run this code, instead of the desired plot, you get the following TypeError: ‘AxesSubplot’ object is not subscriptable: πŸ’¬ Question: How to resolve the TypeError: ‘AxesSubplot’ object is not subscriptable … Read more

How Does the Solidity Voting Smart Contract Work?

With this article, we are starting a journey of going through smart contract examples in Solidity. We’ll first lay out the entire smart contract example without the comments for readability purposes. Then we’ll dissect it part by part, analyze it and explain it. Following this path, we’ll get a hands-on experience with smart contracts, as … Read more