Skip to content
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

Issues with pandas Timedelta - init and addition #444

Closed
Dr-Irv opened this issue Oct 1, 2020 · 3 comments
Closed

Issues with pandas Timedelta - init and addition #444

Dr-Irv opened this issue Oct 1, 2020 · 3 comments
Assignees
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs

Comments

@Dr-Irv
Copy link

Dr-Irv commented Oct 1, 2020

Environment data

  • Language Server version: 2020.9.7
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.7.5

Expected behaviour

No error

Actual behaviour

import pandas as pd

ts = pd.Timestamp("10/1/2020 10:00")
td = pd.Timedelta(minutes=10)

sm = ts + td
print(sm)

reports 3 issues

  1. On the pd.Timestamp line is the same issue as reported in pandas TimeStamp init arguments are wrong #427
  2. On the pd.Timedelta line is the message Argument missing for parameter "value"
  3. On the line with the sum, is the message:
Operator "+" not supported for types "Timestamp" and "Timedelta"
  Operator "+" not supported for types "Timestamp" and "Timedelta"

Possible fix (not sure if the __new__ part is right, but it worked!), which include the suggested fixes in #427 and #436

diff __init__.pyi.ORIG __init__.pyi
119,120c119,120
< class Timedelta(object):
<     def __init__(self, value: Any, unit: str = ..., **kwargs) -> None: ...
---
> class Timedelta(datetime.timedelta):
>     def __init__(self, value: Any = ..., unit: str = ..., **kwargs) -> None: ...
149c149,151
< class Timestamp(object):
---
> class Timestamp(datetime.datetime):
>     @override
>     def __new__(self, ts_input: Any, **kwargs): ...
153,158c155,160
<         freq: Any,
<         tz: Any,
<         unit: str,
<         year: int,
<         month: int,
<         day: int,
---
>         freq: Any = ...,
>         tz: Any = ...,
>         unit: str = ...,
>         year: int = ...,
>         month: int = ...,
>         day: int = ...,
243c245
<     def strftime(self) -> str: ...
---
>     def strftime(self, fmt:str) -> str: ...

@github-actions github-actions bot added the triage label Oct 1, 2020
@judej judej added the typestub Issue relating to our bundled type stubs label Oct 1, 2020
@github-actions github-actions bot removed the triage label Oct 1, 2020
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Oct 2, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.10.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020100-7-october-2020

@cwgonzalez1192
Copy link

Hi, has this issue returned? As far as I can tell, I'm currently seeing it on v2023.2.30. See screenshots below, in which Pylance misidentifies a pd.Timestamp as a pd.Timedelta following . Perhaps it is due to my older Python and Pandas versions:

  • Python v3.6.8
  • Pandas v1.1.5

Location of warning:

image

Description of warning:

image

Version of Pylance:

image

@bschnurr (sorry! just tagging someone who appears to be an active contributor - looks like @jakebailey no longer works on this repo)

@Dr-Irv
Copy link
Author

Dr-Irv commented Feb 22, 2023

  1. Please report any issues with pandas stubs in the pandas-stubs repo. https://github.com/pandas-dev/pandas-stubs
  2. Don't use screenshots - if we are to test this, we need to copy/paste code samples.
  3. With python 3.9, your issue doesn't occur. You might be having a problem because you are using an old version of python as well as a very old version of pandas. We test the stubs with python 3.8 through 3.11, and only with the latest release of pandas (currently 1.5.3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

5 participants