Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Data Wrangling Workshop

You're reading from   The Data Wrangling Workshop Create your own actionable insights using data from multiple raw sources

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781839215001
Length 576 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Dr. Tirthajyoti Sarkar Dr. Tirthajyoti Sarkar
Author Profile Icon Dr. Tirthajyoti Sarkar
Dr. Tirthajyoti Sarkar
Shubhadeep Roychowdhury Shubhadeep Roychowdhury
Author Profile Icon Shubhadeep Roychowdhury
Shubhadeep Roychowdhury
Brian Lipp Brian Lipp
Author Profile Icon Brian Lipp
Brian Lipp
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface
1. Introduction to Data Wrangling with Python 2. Advanced Operations on Built-In Data Structures FREE CHAPTER 3. Introduction to NumPy, Pandas, and Matplotlib 4. A Deep Dive into Data Wrangling with Python 5. Getting Comfortable with Different Kinds of Data Sources 6. Learning the Hidden Secrets of Data Wrangling 7. Advanced Web Scraping and Data Gathering 8. RDBMS and SQL 9. Applications in Business Use Cases and Conclusion of the Course Appendix

6. Learning the Hidden Secrets of Data Wrangling

Activity 6.01: Handling Outliers and Missing Data

Solution:

The steps to completing this activity are as follows:

Note

The dataset to be used for this activity can be found at https://packt.live/2YajrLJ.

  1. Load the data:
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    %matplotlib inline
  2. Read the .csv file:
    df = pd.read_csv("../datasets/visit_data.csv")

    Note

    Don't forget to change the path (highlighted) based on where the CSV file is saved on your system.

  3. Print the data from the DataFrame:
    df.head()

    The output is as follows:

    Figure 6.11: The contents of the CSV file

    As we can see, there is data where some values are missing, and if we examine this, we will see some outliers.

  4. Check for duplicates by using the following command:
    print("First name is duplicated - {}"\
          .format(any(df.first_name.duplicated())))
    print("Last name is...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime