#import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.tsa.stattools import adfuller # Generate synthetic stationary and non-stationary data np.random.seed(17) # Stationary data: White noise stationary_data = np.random.normal(size=82) # Non-stationary data: Random walk non_stationary_data = np.cumsum(np.random.normal(size=82)) # Plot the data plt.figure(figsize=(10,5)) plt.subplot(1, 2, 1) plt.plot(stationary_data) plt.title(‘Stationary Data’) plt.subplot(1, 2, 2) plt.plot(non_stationary_data) […]
KPSS-test
#import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.tsa.stattools import kpss # Generate synthetic stationary and non-stationary data np.random.seed(17) # Stationary data: White noise stationary_data = np.random.normal(size=100) # Create a random walk with larger step size to make it more volatile random_walk = np.cumsum(np.random.normal(scale=2, size=n)) # Increase the scale for […]
Python Validate User Input
Example 1 isalpha Example 2 integer Example 3 float Example 4 custom invalid characters not using isalpha Example 5 date example Define the valid months for the baseball seasonFebruary (2) to October (10)
Python Zip
To start we’re going to create a simple dataframe in python: If you want to watch a YouTube video based around the tutorial there is one embedded slightly below. https://youtu.be/_0PJul0QTY4 Example 1 In this basic example, we have two lists. One for jersey numbers and another for quarterbacks. We will then zip these together in […]
Python Enumerate
To start we’re going to create a simple dataframe in python: If you want to watch a video on our YouTube channel based around the tutorial it’s embedded below. https://youtu.be/ox5yrjKlkxQ Example 1 – Enumerate on List For our first example let’s Enumerate on a list. We will look at a list of sports. sports = […]
Python List Comprehension
List Comprehension allows you to save time by creating a list in one line of code, instead of using a For loop. This is done by applying an expression to each item in the list. If you want to watch a YouTube video based around the article, we have embedded one down below. List Comprehension […]
Python Dictionary Comprehension
In this tutorial, we are going to dive into Dictionary Comprehension. This is a way in which you can create a brand new dictionary in one line of code. There are other types of comprehension in python. In fact we have covered list comprehension in an earlier article. If you want to watch a YouTube […]
Python Match Case Statement
The match case statement in Python introduces a powerful way to handle conditional logic, akin to the switch-case statements found in many other programming languages. By allowing you to match values against a variety of patterns and execute code based on the first pattern that is matched, the match case statement can make your code […]