Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Reading CSVs With Pandas

Give Feedback

This lesson covers a couple different ways to import CSV data into the third party Pandas library. In this video, you’ll learn how to install pandas using pip and, how to use it to read CSV files.

Download

Sample CSV Files (.zip)

643 bytes

Here’s the example CSV file you’ll be using (hrdata.csv):

Name,Hire Date,Salary,Sick Days remaining
Graham Chapman,03/15/14,50000.00,10
John Cleese,06/01/15,65000.00,8
Eric Idle,05/12/14,45000.00,10
Terry Jones,11/01/13,70000.00,3
Terry Gilliam,08/12/14,48000.00,7
Michael Palin,05/23/13,66000.00,8

The following example shows how to read a CSV file and print out its contents using pandas:

import pandas as pd

data_frame = pd.read_csv('hrdata.csv')
print(data_frame)

In addition to learning how to read CSV files and printing their contents, you will see how to use pandas to modify the index on the files you read, parse dates and also how to add headers to CSV files without one.

Comments & Discussion

Gaetano Barreca on Jan. 10, 2020

I tried to installed Pandas without result till I found this: pip3 install pandas

Become a Member to join the conversation.