Lecture

Creating and Inspecting Series and DataFrames

Now that you've been introduced to Pandas, it's time to start building with it.

In this lesson, you'll learn how to create Series and DataFrames from Python lists and dictionaries.

These objects let you store, label, and organize data efficiently, and Pandas makes it straightforward.

Series

A Series is a one-dimensional array with labels. It's like a single column in a spreadsheet.

Below is an example of creating a Series from a list.

Build a Series and a DataFrame
import pandas as pd # Create a Series of daily step counts steps = pd.Series([8000, 9200, 10200], name="Steps") print("Steps Series:", steps)

Series are useful for storing and manipulating single columns of data.


DataFrame

A DataFrame is a two-dimensional table with rows and columns. It's like a spreadsheet.

Below is an example of creating a DataFrame from a dictionary.

Build a Series and a DataFrame
import pandas as pd # Create a Series of daily step counts steps = pd.Series([8000, 9200, 10200], name="Steps") # Create a DataFrame of sales records sales = pd.DataFrame({ "Product": ["Book", "Pen", "Notebook"], "Price": [12.99, 1.50, 4.75] }) print("Steps Series:", steps) print("Sales DataFrame:", sales)

DataFrames are useful for storing and manipulating multiple columns of data.

Quiz
0 / 1

Which Pandas function is used to preview the first few rows of a DataFrame?

.describe()

.info()

.head()

.tail()

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help