Explain Pandas reindexing

Quick Overview

Asks what Pandas reindexing does to a Series or DataFrame when the new labels differ from the old ones. It tests label-based alignment, fill options such as a constant or forward fill, the dtype change caused by missing values, and typical uses like completing a date range.

Explain Pandas reindexing

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

Explain Pandas reindexing. Describe what `.reindex()` does to a Series or DataFrame and when you would use it. ```hint Think in labels Compare the labels the object has before and after the call, and ask where each new label gets its value from. ``` ### What a Strong Answer Covers - What happens to labels that match, labels that are new, and labels left out of the new index - How gaps get filled (a constant or a value taken from a neighbor) and what propagation needs from the index - That reindexing works on rows and on columns - Side effects such as the dtype change when missing values appear - At least one practical use, such as aligning objects or completing a date range ### Follow-up Questions - Why does an integer Series come back as `float64` after reindexing, and how can you keep the integer type? - What happens when you call `.reindex()` on a Series whose index has duplicate labels? - How is `.reindex()` different from `.rename()` and `.set_index()`? - A daily sales series is missing some days. How would you fill them, and when would forward fill be the wrong choice?

Overview: Asks what Pandas reindexing does to a Series or DataFrame when the new labels differ from the old ones. It tests label-based alignment, fill options such as a constant or forward fill, the dtype change caused by missing values, and typical uses like completing a date range.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

Explain Pandas reindexing. Describe what .reindex() does to a Series or DataFrame and when you would use it.

What a Strong Answer Covers Guidance

  • What happens to labels that match, labels that are new, and labels left out of the new index
  • How gaps get filled (a constant or a value taken from a neighbor) and what propagation needs from the index
  • That reindexing works on rows and on columns
  • Side effects such as the dtype change when missing values appear
  • At least one practical use, such as aligning objects or completing a date range

Follow-up Questions Guidance

  • Why does an integer Series come back as float64 after reindexing, and how can you keep the integer type?
  • What happens when you call .reindex() on a Series whose index has duplicate labels?
  • How is .reindex() different from .rename() and .set_index() ?
  • A daily sales series is missing some days. How would you fill them, and when would forward fill be the wrong choice?