Skip to content

DataFrame.interpolate method return type does not honor default inplace argument #691

Closed
@jasonboh

Description

@jasonboh

Using pandas-stubs-2.0.1.230501.

inplace defaults to False, so the below shoudl return a new DataFrame. But pyright thinks the return type is DataFrame | None. Here is some code showing the problem:

import pandas as pd
df: pd.DataFrame = -pd.DataFrame()
df = df.interpolate(method="linear") # pyright reports the below message for this line

Expression of type "DataFrame | None" cannot be assigned to declared type "DataFrame"
  Type "DataFrame | None" cannot be assigned to type "DataFrame"
    Type "None" cannot be assigned to type "DataFrame"

But if I repalce the line with the below, then pyright is happy:

df = df.interpolate(method="linear", inplace=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions