To start we’re going to create a simple dataframe in python: https://youtu.be/REhRhRUcluI Example 1 – if else state location To start we’re going to create a simple dataframe in python: #DataFrame.sample(n=None, frac=None, replace=False, weights=None, random_state=None, axis=None, ignore_index=False) import pandas as pd import random import string import numpy as np Prep The Dataframe # Function to […]
Pandas MultiIndex
https://www.youtube.com/watch?v=XHOmBV4js_Emaybe other ideas#https://pandas.pydata.org/docs/reference/api/pandas.MultiIndex.html#https://pandas.pydata.org/pandas-docs/version/1.2.1/user_guide/advanced.html #https://jessicastringham.net/2019/12/10/multiindex/ #You have now created a multi-index, or hierarchical index (become comfortable with both these terms as you’ll find them used interchangeably)#It may be important to address that despite being able to convert the contents of more than one column into index, we cannot consider that now one row has several indexes. […]
Pandas Replace
import pandas as pd import numpy as np #Similiar to map # .replace() is not operating on the contents of the DataFrame as strings—it’s trying to match the entire value data = { ‘Player’: [‘Barry Bonds’, ‘Hank Aaron’, ‘Babe Ruth’, ‘Alex Rodriguez’, ‘Albert Pujols’, ‘Willie Mays’, ‘Ken Griffey Jr.’], ‘HR’: [762, 755, 714, 696, 703, […]
Pandas Where
https://www.youtube.com/watch?v=Y7HMkDuR_DA&feature=youtu.be The where() function in Pandas is used to replace values in a DataFrame or Series where a condition is not met. It is used to check a data frame for one or more conditions and return the result. To start with we import pandas and numpy import pandas as pd import numpy as np […]
Pandas Mask
To start we’re going to create a simple dataframe in python: https://www.youtube.com/watch?v=XHOmBV4js_E Prep the Data To start we’re going to create a simple dataframe in python: import pandas as pd import numpy as np df = pd.DataFrame({ ‘Hourly_Salary’: [‘500.00’, ‘10000.00’, ‘200.00’, ‘20.00’, np.nan] }) df[‘Hourly_Salary’] = pd.to_numeric(df[‘Hourly_Salary’]) Example 1 – if else state location To […]
Pandas Interpolation
To start we’re going to create a simple dataframe in python: https://youtu.be/BJHwPeRvyPE?si=lvsDqXBjb0mcC4ae import pandas as pd import numpy as np data = { ‘day’: pd.date_range(start=’2025-04-19′, periods=7), ‘temperature’: [np.nan, 30, np.nan, np.nan, 45, 40, np.nan] } df = pd.DataFrame(data) df2 = df.copy() df3 = df.copy() df4 = df.copy() Example 1 To start we’re going to create […]
Pandas diff
By utilizing diff in Python Pandas we can find the difference between different rows and columns. In this article we will go over 9 different examples of utilizing it in different capacities. If you would like to watch a YouTube video based around the written tutorial, it is embedded below. We also have other Pandas […]
Pandas Percentage Change
PCT_change() works nearly identical to .diff() within Python Pandas. The only difference is that we will get a decimal change instead of subtracting the two values. While the Pandas documentation calls this “Percentage Change” it really is the decimal representation of it and we need to multiply our value by 100 to get a true […]
Pandas Expanding
If you want to watch a YouTube video that is based around this Pandas Expanding tutorial, it is embedded below. https://youtu.be/5Bv-5GCj6GQ Tutorial Prep Before we start looking at expanding, we need to import both Pandas and Numpy. Pandas has expanding and Numpy will be utilized when we look at Null values a bit later in […]
Pandas Rank
Learning how to use Pandas Rank is important when it comes to real world data and Interview Questions. In this lesson we will go over 10+ different examples of utilizing it. We will cover the different methods, percentage, null values, and groupby. If you want to watch a YouTube video based around Pandas Rank, it […]