pandas Excel date indexes: checking calendar operations without asking users to re-enter valid dates
Distinguish date meaning from the operations offered by its container. A container mismatch should not automatically become a request for users to re-enter valid dates.
pandas Excel date indexes: checking calendar operations without asking users to re-enter valid dates
Dates may load successfully while the chosen backend returns an index without the calendar method a consumer needs. Clarify the consumer interface instead of asking users to re-enter valid dates. After an explicit conversion, check both method availability and preservation of temporal meaning. [1, 2, 3]
What the primary source establishes
A report describes different index types from numpy_nullable and pyarrow backends when read_excel combines index_col and parse_dates, changing whether to_period can be called. It does not demonstrate corruption of the date values. [1]
The handover decision
The data owner and consumer should name the required calendar operation. After an explicit index conversion, check that the original instant and intended month remain intact. Record source_date, consumer_period, expected_period, and backend so that interface compatibility and date preservation can be assessed separately. [1, 3]
A reference defined before the output
The illustrative source date 2026-01-01 belongs to the period 2026-01. Returning 2026-01 is normal; returning 2026-02 after conversion fails semantic preservation even if the desired method can now be called. The reference period comes from the declared calendar interpretation. [1, 3]
The scoped Truthound check
Truthound Core 3.3.2 can compare normalized expected_period and consumer_period values with ColumnPairValidator. Separately test whether the consumer can actually call to_period. A value comparison cannot establish which methods a Python index class supports. [1, 2, 3]
Limits and alternative choices
Comparing dates does not check whether DatetimeIndex methods are supported. Convert explicitly to the index required by the consumer and run a separate functional test. A consumer that directly supports an Arrow timestamp index need not require conversion to DatetimeIndex. [1, 3]
Application conditions
Prepare date-to-period reference values under the approved calendar policy and retain the backend used for each result.
Alternatives
Convert explicitly to the index required by the consumer and run a separate functional test.
Limitations
Comparing dates does not check whether DatetimeIndex methods are supported.
Evidence
- Event checked
- Subject checked
- Modified
