Styxis
Company
Knowledge

pandas Excel usecols: tracing renamed headers back to the selected sheet columns

Provide a mapping that preserves the user's selected coordinates and business meaning, rather than simply stripping a suffix from the column name.

pandas Excel usecols: tracing renamed headers back to the selected sheet columns

A suffix appearing after selecting only part of a sheet can reflect duplicate-name handling outside the selected range. Removing or replacing the display name alone can merge distinct source columns into one field. An address-based header mapping provides the basis for choosing the consumer's name safely. [1, 2, 3]

What the primary source establishes

A report shows read_excel adding a suffix even when the selected usecols range contains no duplicate names, because another column elsewhere in the sheet shares the name. In its C:D example, col 2 becomes col 2.1. [1]

The handover decision

Compare each selected address's original and parsed headers. Rename only through a mapping approved by the user. Keep sheet_column_address, source_header, parsed_header, and approved_header together so that similarly named columns are not silently treated as the same source. [1, 3]

A reference defined before the output

In the illustrative C:D selection contract, column D is named col 2. A consumer mapping that preserves col 2 satisfies the contract; col 2.1 does not yet match it. Do not remove suffixes globally before confirming the selected address, because another column may legitimately need a different identity. [1, 3]

The scoped Truthound check

Truthound Core 3.3.2 can compare an address-bound approved_header with the actual consumer header using ColumnPairValidator. Retain the sheet and column address instead of relying on names for uniqueness. Removing a suffix is an approved mapping transformation, not a validation result in itself. [1, 2, 3]

Limits and alternative choices

Different columns can share a name across the sheet, so name equality does not establish column identity. Identify columns by address and assign separate unique consumer-facing names. If the consumer contract already adopts pandas' suffix as an identifier, restoring the source name would itself be a contract change. [1, 3]

Application conditions

Prepare source, parsed, and approved headers for the same selected sheet-column address.

Alternatives

Identify columns by address and assign separate unique consumer-facing names.

Limitations

  • Different columns can share a name across the sheet, so name equality does not establish column identity.

Evidence

Event checked
Subject checked
Modified