Data Science

Legends add clarity to complex plots

Matplotlib Legend – A Helpful Illustrated Guide

You’ve plotted some data in Matplotlib but you don’t know which data shows what? It’s time for a legend! How to add a legend in Python’s Matplotlib library? Label it with the label keyword argument in your plot method. Before plt.show(), call plt.legend() your plot will be displayed with a legend. Here’s the minimal example: …

Matplotlib Legend – A Helpful Illustrated Guide Read More »

Python vs Go – Which Language You Should Choose

Both Python and Go are extremely relevant today. Both languages are widely used. However, many people have been switching from Python to the newer and faster language Golang, also known as Go. Go is a much newer language than Python, released by Google in 2009, and it has many advantages over many other programming languages. …

Python vs Go – Which Language You Should Choose Read More »

Matplotlib Subplot – A Helpful Illustrated Guide

Too much stuff happening in a single plot? No problem—use multiple subplots! This in-depth tutorial shows you everything you need to know to get started with Matplotlib’s subplot() function. If you want, just hit “play” and watch the explainer video. I’ll then guide you through the tutorial: To create a matplotlib subplot with any number …

Matplotlib Subplot – A Helpful Illustrated Guide Read More »

An random example

Python’s Random Module – Everything You Need to Know to Get Started

Life is unpredictable. Sometimes good things happen out of the blue like you find $100 on the floor. And sometimes bad things happen, like your flight being canceled because of bad weather. Most programming languages have a module to deal with randomness. Python is no exception coming with the module named random and in this …

Python’s Random Module – Everything You Need to Know to Get Started Read More »

Python Numpy 101: How to Calculate the Row Variance of a Numpy 2D Array?

You can play with the following interactive Python code to calculate the variance of a 2D array (total, row, and column variance). Here’s another practical example: <br />import numpy as np</p> <p># stock prices (3x per day)<br /># [morning, midday, evening]<br />APPLE = np.array(<br />[[50,60,55], # day 1<br />[60,60,65]]) # day 2</p> <p># midday variance<br …

Python Numpy 101: How to Calculate the Row Variance of a Numpy 2D Array? Read More »

NumPy Matrix Multiplication — np.matmul() and @ [Ultimate Guide]

Have you ever tried to multiply two NumPy arrays together and got a result you didn’t expect? NumPy’s multiplication functions can be confusing. In this article, we’ll explain everything you need to know about matrix multiplication in NumPy. Watch the video where I go over the article in detail: To perform matrix multiplication between 2 …

NumPy Matrix Multiplication — np.matmul() and @ [Ultimate Guide] Read More »

How to Sort in Python with the Lambda Function as Key Argument?

This article shows how to sort in Python using the key argument that takes a function as argument. You can use the lambda function to create the function on the fly as shown in the following example: This is one of the most popular Python puzzles on the Finxter app. Before I explain the output, …

How to Sort in Python with the Lambda Function as Key Argument? Read More »