Skip to content

Incorrect inferred type when indexing Pandas dataframe with column list #1075

@janosh

Description

@janosh

Summary

import pandas as pd

df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
cols = ['A', 'B']
sub_df = df[cols] # inferred type is Series[Any] but should be DataFrame[Any] or maybe even DataFrame[int]
$ uv pip show pandas
Using Python 3.13.0 environment at: /Users/janosh/.venv/py313
Name: pandas
Version: 2.3.1

maybe slightly related #851

Version

ty 0.0.1-alpha.19 (e9cb838 2025-08-19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions