Reader small image

You're reading from  The Applied Data Science Workshop - Second Edition

Product typeBook
Published inJul 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781800202504
Edition2nd Edition
Languages
Tools
Concepts
Right arrow
Author (1)
Alex Galea
Alex Galea
author image
Alex Galea

Alex Galea has been professionally practicing data analytics since graduating with a masters degree in physics from the University of Guelph, Canada. He developed a keen interest in Python while researching quantum gases as part of his graduate studies. Alex is currently doing web data analytics, where Python continues to play a key role in his work. He is a frequent blogger about data-centric projects that involve Python and Jupyter Notebooks.
Read more about Alex Galea

Right arrow

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 page is locked
Previous PageNext Page
You have been reading a chapter from
The Applied Data Science Workshop - Second Edition
Published in: Jul 2020Publisher: PacktISBN-13: 9781800202504

Author (1)

author image
Alex Galea

Alex Galea has been professionally practicing data analytics since graduating with a masters degree in physics from the University of Guelph, Canada. He developed a keen interest in Python while researching quantum gases as part of his graduate studies. Alex is currently doing web data analytics, where Python continues to play a key role in his work. He is a frequent blogger about data-centric projects that involve Python and Jupyter Notebooks.
Read more about Alex Galea