Skip to content

With the most recent pandas-stubs, mypy now complains about every call to itertuples() #834

Closed
@Dr-Irv

Description

@Dr-Irv

With the most recent pandas-stubs, mypy now complains about every call to itertuples()
Is there a way that I'm supposed to tell the new release what my column names are?

Sample

import pandas as pd                                                                                 
                                                                                                    
df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [5, 6, 7, 8]})                                           
                                                                                                    
for item in df.itertuples():                                                                        
    a = item.a                                                                                      
    b = item.b     
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

foo.py:6: error: "tuple[Any, ...]" has no attribute "a"  [attr-defined]
foo.py:7: error: "tuple[Any, ...]" has no attribute "b"  [attr-defined]
Found 2 errors in 1 file (checked 1 source file)

Originally posted by @j-carson in #832

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