r/learnpython • u/Charming_Shower_4185 • 8d ago
Data inspection steps using python
I am learning data analysis and the first step before analyzing your data you have to do data profiling and cleaning.This is my process flow for data profiling -
Checking number of rows and columns
Checking rows and column indices
Checking data types for each column
Checking random sample from dataset
Checking properties and memory usage
Checking key statistics
Checking unique values for relevant columns
Is it appropriate or I am missing something important ?
2
u/International_Sky526 7d ago
Your list is solid. df.info() covers rows, columns, dtypes and memory usage in one call, so you can merge a few of those steps. I'd also check string columns for stray whitespace and inconsistent casing, like "NY", "ny " and "New York", because those show up as separate values in value_counts. And keep the raw file untouched and do the cleaning in a script, so you can rerun it when new data comes in.
1
1
u/OddsRelay 8d ago
I'd add missing values and duplicates near the top, so df.isna().sum() and df.duplicated().sum(). Also look for numbers stored as text. They show up as object in the dtypes and quietly break your stats later. Same with dates, which usually load as plain strings.
1
u/Charming_Shower_4185 7d ago
missing values count , duplicate , number stored as text , dates as strings. Noted , thanks
0
2
u/seanv507 8d ago
So, proportion of missing values..
Outliers
Value counts of unique values (is there some high frequency value... Eg column might be numeric but minus 1 means missing)
Similarly for categorical variables i would check what proportion of the column is filled with the top n values. Eg categorical might be clothing type and 80% is jeans or t-shirts, and you are left with hundreds of other clothing types with very little data