1. Learn
  2. /
  3. Courses
  4. /
  5. Importing Data in Python

Connected

Exercise

Using pandas to import flat files as DataFrames (1)

In the last exercise, you were able to import flat files containing columns with different datatypes as numpy arrays. However, the DataFrame object in pandas is a more appropriate structure in which to store such data and thankfully we can easily import files of mixed data types as DataFrames using the pandas functions read_csv() and read_table().

Instructions

100 XP
  • Import the pandas package using the alias pd.
  • Read titanic.csv into a DataFrame called df. The file is already stored in the file object.
  • In a print() call, view the head of the DataFrame.