Posts

Showing posts with the label EDA

dropna

Image
Working with Missing Data in Pandas Working with Missing Data in Pandas In this blog post, we will explore various techniques for handling missing data using the Pandas library in Python. Specifically, we will focus on removing rows or columns with NaN or None values using different methods provided by Pandas. Setup We begin by importing the required libraries and reading the CSV file containing the movie data. import pandas as pd import numpy as np loc = 'https://raw.githubusercontent.com/aew5044/Python---Public/main/movie.csv' m = pd.read_csv(loc) Creating a Subset and Introducing Missing Values We create a subset of the data, keeping only the columns we want to work with. Additionally, we introduce NaN values in specific rows and columns. m1 = m[['movie_title','director_name','actor_1_name']][0:5] m1.loc[0:1,'director_name'] = np.nan m1.loc[0:2,'actor_1_name...

CategoricalDtypes used in Filtering Data

Image
CategoricalDtypes in Pandas CategoricalDtypes can also be used for filtering.  For example, if we have low, high, and medium survey responses, we can use CategoricalDtypes to filter all responses less than or equal to medium. There are three basic steps! Create the CategoricalDtype. Apply the CategoricalDtype to the pandas Series. Filter the data. It is just that simple.  Let's look at an example. When we print the filtered_df, we can see we have our desired output.  It is just that simple! Link to Google Colab with the code!