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 Applied Data Science Workshop

You're reading from   The Applied Data Science Workshop Get started with the applications of data science and techniques to explore and assess data effectively

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781800202504
Length 352 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alex Galea Alex Galea
Author Profile Icon Alex Galea
Alex Galea
Arrow right icon
View More author details
Toc

3. Preparing Data for Predictive Modeling

Activity 3.01: Preparing to Train a Predictive Model for Employee Retention

Solution:

  1. Check the head of the table by running the following command:
    %%bash
    head ../data/hr-analytics/hr_data.csv

    Note how we specify paths relative to the notebook's location. In this case, we need to step back one directory (by using ".." in the file path), which brings us to the root folder for the project. Then, we look in data/hr-analytics for hr_data.csv.

    This will generate the following output:

    Figure 3.25: Printing the head of hr_data.csv with bash

  2. If you cannot run bash in your notebook, run the following command:
    with open('../data/hr-analytics/hr_data.csv', 'r') as f:
        for _ in range(10):
            print(next(f).strip())

    The output is as follows:

    Figure 3.26: Printing the head of hr_data.csv with Python

    Judging by the output, convince yourself that it...

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 R$50/month. Cancel anytime