Last active
April 22, 2024 14:59
-
-
Save Dre1k23/67b290fcebff9e065a2f4aa2dc65358f to your computer and use it in GitHub Desktop.
mb some explain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Convert all attributes to lowercase | |
( | |
df = df.map(lambda x : x.lower() if isinstance(x, str) else x) | |
) | |
#Assign the correct data format to the attributes that need it. | |
( | |
df['your column name'] = pd.to_datetime(df['your column name']) | |
dfq = df | |
) | |
#Let's reduce the attributes to one data type | |
( | |
column_factorize = df.select_dtypes(include = 'object') | |
df2 = column_factorize.apply(lambda x: pd.factorize(x)[0]) | |
df = pd.concat([df2, df[['your column name', 'your column name']]], axis = 1) | |
df | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import warnings | |
warnings.filterwarnings('ignore') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#we need to chek how many nulls we have | |
( | |
df.isnull().sum() | |
) | |
#We can also determine critical values from missing values | |
( | |
critical_nulls = 0.3 | |
missing_ratios = dfq.isnull().mean() | |
critical_columns = missing_ratios[missing_ratios > critical_nulls] | |
if not critical_columns.empty: | |
print("Critical column:") | |
print(critical_columns) | |
else: | |
print("No critical columns.") | |
) | |
#To estimate the error with the permissible number of missing values, we can use the following | |
( | |
df.describe(include = "all") | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hope this helps you to work with data.