Closed
Description
Observed in PR #36305
When adding check on inferred type for each level in MultiIndex for columns, error message pops up in CI (Typing validation with mypy):
pandas/io/parquet.py:59: error: "Index" has no attribute "levels"; maybe "nlevels"? [attr-defined]
I understand that single-level Indexes do not have the "levels" attribute while MultiIndexes have the "levels" attribute. It seems that mypy static type checking may have inferred "df.columns" as Index type by default, hence flagging the error when using "df.columns.levels" in the code change.
Would it make sense to add a "levels" attribute to "Index" for consistency with MultiIndex, or are there any possible workarounds for this mypy error?
Metadata
Metadata
Assignees
Labels
No labels