October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Pandas Series vs DataFrame: What’s the Difference?

A pandas Series is one-dimensional; a DataFrame is a two-dimensional labeled table. Learn how column selection affects the returned object and how to convert between shapes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A pandas Series is a one-dimensional labeled sequence; a DataFrame is a two-dimensional labeled table. The distinction matters when selecting columns or passing data to code that expects a particular shape: df["Age"] returns a Series, while df[["Age"]] keeps the result as a one-column DataFrame.

Series vs DataFrame at a glance

Feature Series DataFrame
Dimensions One-dimensional Two-dimensional
Labels An index labels the values An index labels rows; columns have their own labels
Data organization One labeled sequence A table of columns, which can contain different data types
Example selection df["Age"] returns a Series df[["Age"]] returns a DataFrame

Both objects use labels, but a Series has one axis—the index—while a DataFrame has row and column axes. A DataFrame can contain columns with different types; each individual Series represents one column’s values. See the official pandas overview of the data pandas handles and the DataFrame and Series API references (pandas 3.0.6 documentation).

Why a single selected column may still be a Series

Square brackets do not guarantee a DataFrame. With one column label, df["Age"] selects that column as a Series. If later code expects a two-dimensional table, that one-dimensional result can cause a shape mismatch even though it displays like a column.

ages = df["Age"]       # Series: one-dimensional
ages_table = df[["Age"]]  # DataFrame: two-dimensional, one column

The difference is the type and dimensionality of the returned object, not how its values happen to appear when displayed. The pandas tutorial explains how to select a subset of a DataFrame.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select rows and columns together

Use .loc when selecting by labels, or .iloc when selecting by integer positions. Both let you specify rows and columns; the selection’s resulting shape depends on how those axes are indexed.

# Rows with index labels, and the Age column label
df.loc["row_label", "Age"]

# Rows and columns by integer position
df.iloc[0, 0]

These single-cell examples return a scalar value, whereas selecting multiple rows or columns can return a Series or DataFrame. Choose the indexer and selection shape to match the object your next operation expects.

Convert a Series to a DataFrame

Call Series.to_frame() to make a one-column DataFrame. Use its name parameter to specify the resulting column label:

ages_table = ages.to_frame()
ages_table_named = ages.to_frame(name="Age")

The conversion preserves a table shape even though it contains just one column. See the official Series.to_frame API reference (stable documentation surfaced as pandas 3.0.4).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the shape when it matters

If downstream code requires a particular object shape, inspect it rather than relying on how pandas displays it:

  • obj.ndim reports the number of dimensions: a Series has 1 and a DataFrame has 2.
  • obj.shape reports the size of its axes; a Series has one length, while a DataFrame has row and column sizes.
  • type(obj) identifies whether the object is a Series or DataFrame.

For example, check ages.ndim and ages_table.ndim after selecting a column if the next function is sensitive to one-dimensional versus two-dimensional input.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.