Skip to content

DataFrame.pct_change typing for None missing #992

Closed
@loicdiridollou

Description

@loicdiridollou

Describe the bug
A clear and concise description of what the bug is.
For the pd.DataFrame.pct_change the documentation allows the None method but the typing only supports str.
This results in an error from pyright to be raised.

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.
df = pd.DataFrame({"x": [1, 2, 2, 3, 3], "y": [10, 20, 30, 40, 50]})
df.pct_change(fill_method=None)

This example will yield the error:

error: Argument "fill_method" to "pct_change" of "DataFrame" has incompatible type "None"; expected "str"  [arg-type]

While the documentation allows for None:
Screenshot 2024-09-03 at 6 04 46 PM

Please complete the following information:

  • OS: MacOs
  • OS Version Sonoma 14
  • python version 3.12.4
  • version of type checker 1.1.378
  • version of installed pandas-stubs v2.2.2.240807

Additional context
Add any other context about the problem here.

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