The Numpy Library

The Ultimate Guide to NumPy Cumsum in Python

Definition np.cumsum(x): The function computes the cumulative sum of a NumPy array. For an array x with elements [a b c d] the cumulative sum is [a a+b a+b+c a+b+c+d]. Formally, each array element with index i is the sum of all elements with index j<i. numpy.cumsum(a, axis=None, dtype=None, out=None) Arguments: a — Array-like data …

The Ultimate Guide to NumPy Cumsum in Python Read More »

[NumPy vs Python] What are Advantages of NumPy Arrays over Regular Python Lists?

The Python built-in list data type is powerful. However, the NumPy array has many advantages over Python lists. What are they? Advantages NumPy Advantages Python Lists Multi-dimensional Slicing Library-Independent Broadcasting Functionality Intuitive Processing Speed Less Complicated Memory Footprint Heterogeneous List Data Allowed Many Convenience Methods Arbitrary Data Shape (Non-Square Matrix) Let’s dive into the most …

[NumPy vs Python] What are Advantages of NumPy Arrays over Regular Python Lists? Read More »

Photo by Gensa Hub on Unsplash

Matplotlib Animation – A Helpful Illustrated Guide

Creating animations in matplotlib is reasonably straightforward. However, it can be tricky when starting, and there is no consensus for the best way to create them. In this article, I show you a few methods you can use to make amazing animations in matplotlib. Matplotlib Animation Example The hardest thing about creating animations in matplotlib …

Matplotlib Animation – A Helpful Illustrated Guide Read More »

How to Sum List of Lists in Python? [Rows]

Problem: Given a list of lists representing a data matrix with n rows and m columns. How to sum over the rows of this matrix? In this article, you’re going to learn different ways to accomplish this in Python. Let’s ensure that you’re on the same page. Here’s a graphical representation of the list of …

How to Sum List of Lists in Python? [Rows] Read More »

How to Sum List of Lists in Python? [Columns]

Problem: Given a list of lists representing a data matrix with n rows and m columns. How to sum over the columns of this matrix? In this article, you’re going to learn different ways to accomplish this in Python. Let’s ensure that you’re on the same page. Here’s a graphical representation of the list of …

How to Sum List of Lists in Python? [Columns] Read More »

How to Calculate the Column Standard Deviation of a DataFrame in Python Pandas?

Want to calculate the standard deviation of a column in your Pandas DataFrame? In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of variance: it’s the average squared deviation of the list elements from the average value. You can do this by using the pd.std() function that …

How to Calculate the Column Standard Deviation of a DataFrame in Python Pandas? Read More »

How to Get the Standard Deviation of a Python List?

This article shows you how to calculate the standard deviation of a given list of numerical inputs in Python. The standard deviation is defined as the square root of the variance. In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of variance: it’s the average squared deviation …

How to Get the Standard Deviation of a Python List? Read More »

How to Get the Variance of a List in Python?

This article shows you how to calculate the variance of a given list of numerical inputs in Python. In case you’ve attended your last statistics course a few years ago, let’s quickly recap the definition of variance: it’s the average squared deviation of the list elements from the average value. So, how to calculate the …

How to Get the Variance of a List in Python? Read More »

numpy.fv — Calculate the Future Value of an Investment in Python

NumPy is full of those little helper functions that boost your productivity and make coding a lot of fun. The NumPy’s fv() function is one of those helpers for financial analysis that will save you a lot of time if you’re working in the financial sector—or if you’re just using NumPy to analyze your own …

numpy.fv — Calculate the Future Value of an Investment in Python 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 »