EDA for Data Analysis or Data Visualization is very important. It gives a brief summary and main characteristics of data. According to a survey, Data Scientist uses their most of time to perform EDA tasks.
EDA involves a lot of steps including some statistical tests, visualization of data using different kinds of plots, and many more. Some of the steps of EDA are discussed below:
Data Quality Check: It can be done using some Pandas library functions i.e.
df.describe() , df.shape , df.info(), df.dtypes()
These functions are generally used to find missing values, duplicate values, features, data-types, summary of data, etc.
Statistical Test: Some statistical test i.e. Pearson correlation,Spearman correlation, Kendall test etc is done to get correlation between features . What I mean to correlation is that how one feature is dependent on other feature. It can be done in Python using stats library.
Quantitative Test: Some quantitative test is used to find the spread of numerical features, count of categorical features. It can be implemented in Python using the functions of the pandas library.
Visualization: Feature visualization is very essential to get an understanding of the data. Graphical techniques like bar plots, pie charts are used to get an understanding of categorical features, whereas scatter plots, histograms are used for numerical features.
To perform the above-mentioned tasks we need to type several lines of code. Here the pandas-profiling open-source library comes into the play, which can perform all these tasks using just 1 line of code.
Wow! Just one line of code!š¤
Yes, you read it correct only one line of code. Itās possible in Python using itās pandas-profiling open-source library. Also the result of EDA using pandas-profiling can be displayed in a Jupyter notebook or can be converted to an HTML page.
Now, without wasting any time letās see how to do thisš²
Installation:
There are many ways to install Pandas-profiling library but weāll use simplest one using pip:
pip install pandas-profiling
Import libraries:
To use the pandas-profiling library for EDA, we need to import some required libraries:
import pandas as pd
import numpy as np
from pandas_profiling import ProfileReport
Now EDA using one line code:
profile = ProfileReport(pd.read_csv(ātitanic.csvā),title='Pandas Profiling Report',html={'style': {'full_width': True}}, sort="None"))
Yes, thatās it, weāve completed with exploratory data analysis. Results can be observed in Jupyter notebook or Google colab itself or the file can be saved in HTML format and used in a web browser.
#to view result in jupyter notebook or google colab
profile.to_widgets()
# to save results of pandas-profiling to a HTML file
profile.to_file("EDA.html")
EDA for the Titanic Dataset:
The dataset used for exploratory data analysis using the pandas-profiling library is downloaded from Kaggle.
Here is work sample of EDA for Titanic Dataset
Output:
The output of EDA for Titanic Dataset will looks like this :
Note:
If you are a beginner in Data Science I wonāt suggest you to perform EDA using pandas-profiling. I prefer to do my EDA with self-defined functions using several Python libraries.
For beginners, it is good to start doing EDA using the pandas library and writing Python code before trying this library, as it is more important to be equipped with the fundamental knowledge and programming practices.
If you want to know about NumPy library than Iāll suggest NumPy: Everything A Data Scientist Should Know article.
If you want to know how to convers PDFs into an Audiobook than click here.
Thank You so much for Reading! follow for more stuff of Data Science.