← Courses

Pandas, Hands-On Data with Python

Data Science

Core pandas · Lesson 3 of 10

Creating, reading and writing data

DataFrames and Series

pandas has two core objects:

  • A DataFrame is a table: rows and named columns.
  • A Series is a single column, a list of values with a label.

Here is a DataFrame built from a dictionary. Each key becomes a column name, and each list holds that column's values.

Python

Run it. You get a tidy table, with an automatic row number index down the left.

In real projects you usually load data from a file instead of typing it:

# Reading a CSV file (shown for reference; needs the file to be present)
data = pd.read_csv("students.csv")

read_csv is how most data science begins. The result is a DataFrame, exactly like the one you built above.

Exercise

Exercise — check your understanding

Build a DataFrame called crops with two columns: crop holding "Maize", "Cassava", "Rice", and yield_tonnes holding 12, 9, 15.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →