Importing Datasets

This is part of the “Intro to Data Analysis with Python” series of posts, with content from the Enki app. If you stumbled upon this, you could start from the beginning.

Previously we learned how to create a Series and a DataFrame and what they are.

Now we will learn how to import a dataset into a DataFrame.

Before that, we should first decide if we are importing from an external or a local source. After that, we have to decide what type of file we want to import.

For now, we will import a CSV file called "netflix_titles.csv".

Imported Dataset

If we are importing externally, we can just use pandas .read_csv module with the URL  inside.

On the other hand, if we are importing from a local source, we first have to make sure the file is in our working Python directory[1].

Now we can import it into our project.

💡 Add this code to the same notebook we created in the previous workout.

If you want to use the same dataset, you can download it using the link in the Learn More section.


[1: Working Directory]

To check your current working directory, you have to first import the os library and use its .getcwd() module.

The .getcwd() module will output the current working directory.

Just locate the folder using the path provided by the .getcwd() module and move the CSV file there.

To check if a file is in a specific folder, we need to use the .listdir() method from the same module:

We can print the files in a list:

Or use a for loop:

Learn More

Stefan Stojanovic

Content Manager

About Enki

  • AI-powered, customized 1:1 coaching
  • Fully customized to team needs
  • Pay only for active learners and results

More articles