Skip to content

Series[Any] should accept __add__ #1541

@loicdiridollou

Description

@loicdiridollou

Describe the bug
In many use cases, I have seen code extracting a column from a dataframe then adding a string.
In the current setup this is now barred but I believe we should be a little lenient when it comes to not being too strict since the types can't be inferred from a dataframe when selecting a column.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
  2. Indicate which type checker you are using (mypy or pyright).
  3. Show the error message received from that type checker while checking your example.
import pandas as pd

df = pd.Series(["a", "b"]).to_frame()
df[0] + "c3"  # Operator "+" not supported for types "Series[Any]" and "Literal['c3']" [repor│

Please complete the following information:

  • OS: MacOS
  • OS Version [e.g. 22]
  • python version 3.14
  • version of type checker 1.19
  • version of installed pandas-stubs main

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Numeric OperationsArithmetic, Comparison, and Logical operationsSeriesSeries data structure

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions