Earn 20 XP


Learning Objectives

  • What is DataFrame?
  • Create a DataFrame

What is a DataFrame?

  • Two-dimensional table
  • Made up of a collection of Series
  • Structured with labeled axes (rows and columns)

A data frame looks like a table, as shown in the image here:

image.png

Create a DataFrame

  • You can create a DataFrame using a Python list or a NumPy array:

image.png

  • Exercise: Try creating a DataFrame using a NumPy array.
  • Don’t like python default index starting from ‘0’? Well, you can give your own column and row indexes:

image.png

  • You can create a DataFrame using dictionary:

image.png

A Column is a Series

  • A DataFrame is a collection of series.
  • A series is a column in a table or a DataFrame.

image.png

  • There are 3 series in the given DataFrame - ‘Regd. No’, ‘Names’ and ‘Marks%’.