Skip to content

Conversation

@sjdemartini
Copy link
Contributor

The total_seconds method returns a float, rather than an int. I noticed this problem seeing incorrect typing within VSCode.

The correct return type can be tested/confirmed as follows:

import pandas as pd
ptd = pd.to_timedelta(1234.5678, unit="s")
print(ptd.total_seconds())  # 1234.5678
print(type(ptd.total_seconds()))  # <class 'float'>
print(type(ptd))  # <class 'pandas._libs.tslibs.timedeltas.Timedelta'>

And similarly in the types within the pandas repo https://github.com/pandas-dev/pandas/blob/7f97e27241dc520038d8d1b0de114afec3ad24df/pandas/_libs/tslibs/timedeltas.pyi#L50

The `total_seconds` method returns a float, rather than an int.

This can be tested/confirmed as follows:

```python
import pandas as pd
ptd = pd.to_timedelta(1234.5678, unit="s")
print(ptd.total_seconds())  # 1234.5678
print(type(ptd.total_seconds()))  # <class 'float'>
print(type(ptd))  # <class 'pandas._libs.tslibs.timedeltas.Timedelta'>
```
@gramster gramster merged commit c2b5349 into microsoft:main Feb 23, 2022
@sjdemartini sjdemartini deleted the patch-1 branch February 23, 2022 02:39
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

Successfully merging this pull request may close these issues.

2 participants