From a CSV file
CSV files are a common way to store tabular data, and pandas
is the easiest way to read them into Python. And easy is no exaggeration, you only need one function to import a CSV file with pandas
, and it automatically converts the file to a DataFrame.
In this exercise, you are going to explore the pandas
function read_csv()
and its arguments to read in a CSV file, which contains records of wildlife strikes. Before starting, run help(pd.read_csv)
in the console to view the arguments for the read_csv()
function. There are many, but understanding your options will save you lots of time when importing your data.
This exercise is part of the course
Python for MATLAB Users
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load strikes from strikes.csv
strikes = pd.read_csv('____')
print(strikes.head())