Skip to content

Series.fillna(None) #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amgcc opened this issue Mar 2, 2024 · 3 comments
Closed

Series.fillna(None) #884

amgcc opened this issue Mar 2, 2024 · 3 comments

Comments

@amgcc
Copy link
Contributor

amgcc commented Mar 2, 2024

Describe the bug
Series.fillna with None value fails for missing overload. It could be argued this is bad practice but it is valid according to the docs.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
import numpy as np
import pandas as pd


def main():
    ffill_limit: int = 2
    sr1 = pd.Series([0, np.nan, 5, np.nan, np.nan, np.nan, 7])
    sr2 = sr1.fillna(method="ffill", limit=ffill_limit)
    print(sr2.values)


if __name__ == '__main__':
    main()
  1. Indicate which type checker you are using (mypy or pyright).
    mypy
  2. Show the error message received from that type checker while checking your example.
scratch/fillna.py:7: error: No overload variant of "fillna" of "Series" matches argument types "str", "int"  [call-overload]
scratch/fillna.py:7: note: Possible overload variants:
scratch/fillna.py:7: note:     def fillna(self, value: str | bytes | date | datetime | timedelta | datetime64 | timedelta64 | bool | int | float | Timestamp | Timedelta | complex | NAType | dict[Any, Any] | Series[float] | DataFrame | None = ..., *, axis: Literal['index', 0] = ..., limit: int | None = ..., downcast: dict[Any, Any] | None = ..., inplace: Literal[True]) -> None
scratch/fillna.py:7: note:     def fillna(self, value: str | bytes | date | datetime | timedelta | datetime64 | timedelta64 | bool | int | float | Timestamp | Timedelta | complex | NAType | dict[Any, Any] | Series[float] | DataFrame | None = ..., *, axis: Literal['index', 0] = ..., limit: int | None = ..., downcast: dict[Any, Any] | None = ..., inplace: Literal[False] = ...) -> Series[float]
scratch/fillna.py:7: note:     def fillna(self, value: str | bytes | date | datetime | timedelta | datetime64 | timedelta64 | bool | int | float | Timestamp | Timedelta | complex | NAType | dict[Any, Any] | Series[float] | DataFrame | None = ..., *, axis: Literal['index', 0] = ..., inplace: bool = ..., limit: int | None = ..., downcast: dict[Any, Any] | None = ...) -> Series[float] | None

Please complete the following information:

  • OS: [e.g. Windows, Linux, MacOS] Linux
  • OS Version [e.g. 22] Fedora 7
  • python version 3.11.8
  • version of type checker 1.8.0
  • version of installed pandas-stubs 2.2.0.240218
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Mar 4, 2024

The issue here is that method has been deprecated since version 2.1, so it is removed from the stubs.

So this is really a docs issue, or maybe we don't want to allow None. Created pandas-dev/pandas#57723

@amgcc
Copy link
Contributor Author

amgcc commented Mar 5, 2024

I was able to work around this in my case with Series.ffill directly. If this usage is deprecated, then there is nothing to do here. You can close this issue if you agree.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Mar 5, 2024

I was able to work around this in my case with Series.ffill directly. If this usage is deprecated, then there is nothing to do here. You can close this issue if you agree.

Yes, we will close. Discussion at pandas-dev/pandas#57723 indicates that this won't be supported in the future.

@Dr-Irv Dr-Irv closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants