Python Tutorial: Exploratory data analysis
Key Takeaways
This video tutorial demonstrates exploratory data analysis using Python, focusing on counting unique values, handling missing data, and calculating summary statistics to identify outliers and data points that require further investigation. The tutorial utilizes the Pandas library and methods such as info, value_counts, and describe to analyze a dataset.
Full Transcript
in this video I will show you how we can use exploratory data analysis to help identify data that need further investigation the most basic analysis we can do is count the unique values in our data we can use the info method to get the data type of each column here I will show you the frequency counts for the non numeric continent country and fertility columns and the numeric population column the performer frequency count we first select the column we want to perform a frequency count on if the column name does not contain any special characters spaces and is not a name of a Python function we can select the column directly by its name using dot notation it works the same way as subsetting using bracket notation once we have the column selected we can use the value counts method on the selected column I like to use the drop na equals false parameter since it will also count the number of missing values if there are any the continent column does not have a missing value so num will be reported value counts will print out the counts for each unique value of a column in descending order note that even though we counted a column of the object D type the results of value counts will be of the type int another way we can select columns is using the bracket notation here is the same code in output as before this time using bracket notation to select a column now we will count the number of observations for each country in our data since there are too many countries to show at once I'm using the head method to only return the top five counts in this example I'm chaining together methods I'm slicing and getting the value counts just like before we expect each country to have only one observation a Sweden has two this will require us to investigate this data point further the fertility column is the column we expect it to be numeric was stored as a string this is because we have a string name missing in the column this is why the fertility column has the wrong key type it also alerts us that we need to recode the missing string if your column has missing values it will also be counted provided you pass the drop na equals false parameter here you see we have 42 missing values in the column another type of EDA we can do is calculate summary statistics on numeric columns this can help spot outliers in our data there are many working definitions for outliers one definition is a value that is considerably higher or lower than the rest of the data you can consult the data can statistics course for more detailed definitions of outliers outliers are observations of interest we want to investigate further for data cleaning we can quickly calculate summary statistics on our data by using the describe method only the columns that have a numerical type will be returned describe returns a number of non missing values the mean standard deviation minimum 25th 50th and 75th percentiles of our data where the 50th percentile is the median and finally the maximum value of our data a quick scan down the population results show that the maximum population value is 2.3 billion people our data comes from 2012 no country had this population then now it's your turn to calculate descriptive statistics for exploratory data analysis to see what needs cleaning in your data
Original Description
Want to learn more? Take the full course at https://learn.datacamp.com/courses/cleaning-data-in-python at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
In this video, I will show you how we can use exploratory data analysis to help identify data that need further investigation.
The most basic analysis we can do is count the unique values in our data.
We can use the info method to get the data type of each column. Here, I will show you the frequency counts for the non-numeric continent, country and fertility columns, and the numeric population column.
To perform a frequency count, we first select the column we want to perform a frequency count on.
If the column name does not contain any special characters, spaces, and is not a name of a Python function, we can select a column directly by its name using dot notation.
It works the same way as subsetting using bracket notation.
Once we have the column selected, we can use the value_counts method on the selected column.
I like to use the dropna equals False parameter since it will also count the number of missing values if there are any.
The continent column does not have a missing value, so none will be reported.
value_counts will print out the counts for each unique value of a column in descending order.
Note that even though we counted a column of the object dtype, the results of value_counts will be of dtype int.
Another way we can select columns is using the bracket notation. Here is the same code and output as before, this time using the bracket notation to select a column.
Now we will count the number of observations for each country in our data. Since there are too many countries to show at once, I am using the head method to only return the top 5 counts.
In this example I am chaining together methods, I am slicing and getting the value counts just like before.
We expect each country to have only 1 observation, but Sweden has 2. This
Playlist
Uploads from DataCamp · DataCamp · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
More on: Python for Data
View skill →Related Reads
📰
📰
📰
📰
Astro Chat That Starts With Your Kundli, Not a Generic Horoscope
Dev.to AI
The Docs Draft Pipeline: What an AI May Write and What You Must Own
Dev.to · Avery Lin
Operationalizing the Splunk AI Assistant for Faster Triage and SPL Generation
Medium · AI
CIOs are on notice – vSphere 8 times out in October 2027
The Register
🎓
Tutor Explanation
DeepCamp AI