Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk2 min

How to Use Pandas Concat with Ignore Index

Use ignore_index=True with pd.concat to assign fresh labels along the concatenation axis. See what changes for rows and columns, and when to keep the original index or use keys.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pass ignore_index=True to pd.concat when you want a new, consecutive index along the axis being concatenated. For the usual row-wise operation, that gives the combined DataFrame row labels from 0 onward:

result = pd.concat([df1, df2], ignore_index=True)

Reset row labels while concatenating DataFrames

For example, suppose two DataFrames have indexes that identify rows only within their original inputs:

As an Amazon Associate I earn from qualifying purchases.

import pandas as pd

df1 = pd.DataFrame({"name": ["Ada", "Grace"]}, index=[10, 11])
df2 = pd.DataFrame({"name": ["Linus"]}, index=[42])
combined = pd.concat([df1, df2], ignore_index=True)

With the default axis=0, pandas concatenates rows and assigns the result a new index: RangeIndex(start=0, stop=3, step=1) in this example. The values in the name column remain unchanged. The pandas 3.0.5 API documentation defines the option as not using index values along the concatenation axis and labeling the resulting axis from 0 through n - 1.

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

The same option works for Series:

result = pd.concat([s1, s2], ignore_index=True)

The API reference demonstrates concatenating two two-element Series; the resulting labels are 0, 1, 2, and 3.

What ignore_index changes—and what it does not

ignore_index=True replaces labels only on the axis along which concatenation happens. It does not discard every label or determine how columns are matched.

  • Default axis=0: pandas stacks rows and replaces row-index labels. Columns are still aligned by name.
  • axis=1: pandas concatenates columns, so ignore_index=True replaces the output column labels. Row indexes still matter when pandas aligns the inputs.

For row-wise concatenation, the join setting controls which columns appear. The default join='outer' takes the union of input columns; join='inner' keeps their intersection. These behaviors are described in the pandas merging, joining, and concatenation guide.

Choose whether to preserve labels or record input identity

Use ignore_index=True when original row labels are not useful in the result. If those labels carry meaning, leave the option out so pandas preserves them. If you want to identify which input contributed each row, use keys to add an outer level to the result index instead of discarding the concatenation-axis labels.

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

In pandas 3.0, do not combine ignore_index=True with non-None keys: the combination raises ValueError, as specified in the pandas 3.0.0 release notes.

Concatenate once rather than repeatedly in a loop

When collecting many DataFrames or Series, gather them first and call pd.concat once:

frames = [df1, df2, df3]
result = pd.concat(frames, ignore_index=True)

The API documentation recommends collecting objects before concatenating, and the user guide warns that repeated concatenation can create unnecessary copies. This approach also makes the desired index behavior explicit for the final combined result.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use concat for stacking, not relational matching

ignore_index changes labels on the concatenation axis; it does not match records by a key or replace relational operations. If the task is to combine rows or columns along an axis, use concat. If it is to match records by shared key columns or indexes, consult the pandas guide’s sections on merging and joining.

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

For current code, use pd.concat rather than the former DataFrame.append method. The pandas 1.5.3 reference marks append deprecated since pandas 1.4.0 and recommends concat.

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.