Back to PANDAS FOR DATA ANALYTICS

DataFrame & Series Basics: Selecting Rows and Columns

Learn the core architecture of Pandas DataFrames and Series, bracket notation vs dot notation, and selecting rows and columns using .loc[] and .iloc[].

34 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Ready to continue?

Mark this lesson as complete when you're ready to proceed.

Key moments

  1. DataFrame as a Table — DataFrames are the primary pandas data structure, displayed as rows and columns, similar to a spreadsheet table.
  2. DataFrame Mental Model — Conceptually, a DataFrame is similar to a Python dictionary where keys are columns and values are lists representing the rows.
  3. Creating a DataFrame — A DataFrame can be created directly from a dictionary of lists using `pd.DataFrame()`.
  4. Accessing Columns (Series) — Accessing a single column using bracket notation returns a Series object, which is a 1D array of data.
  5. Series Definition — A Series is a one-dimensional array of data, and a DataFrame is a container for multiple Series objects.
  6. Bracket vs. Dot Notation — Bracket notation is preferred for column access because dot notation can fail if the column name conflicts with a DataFrame method.
  7. Selecting Multiple Columns — Multiple columns are selected by passing a list of column names inside double brackets, which returns a subset DataFrame.
  8. Row Selection with Iloc — Rows can be accessed by their integer position using the `.iloc` indexer.
PDF notes

Frequently asked questions

What is the difference between a DataFrame and a Series?

A DataFrame is a 2D table (rows and columns); a Series is a 1D array representing a single column of data.

Why is accessing a single column like accessing a dictionary key?

Pandas DataFrames are conceptually built like dictionaries where keys are column names and values are lists of data (the rows).

Why does selecting multiple columns return a DataFrame instead of a Series?

A Series can only hold one column of data. Since multiple columns are selected, the result must be a 2D structure (a DataFrame).

What is the index on the far left of the DataFrame?

The index provides a unique identifier for each row. It is used for efficient data lookup and alignment, and will be covered in detail in the next lesson.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.