-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
DOC: The value
parameter of pandas.Timedelta
can also accept float
#60044
Comments
Hello! I tested this method and I found that although pd.Timedelta can accept float values numbers, the result only takes the integer part. For example
|
@ZKaoChi Hi! Thanks for looking into this. The default In [11]: pd.Timedelta(3.5, 'hours')
Out[11]: Timedelta('0 days 03:30:00')
In [12]: pd.Timedelta(3, 'hours')
Out[12]: Timedelta('0 days 03:00:00')
In [15]: pd.Timedelta(3, 'W')
Out[15]: Timedelta('21 days 00:00:00')
In [16]: pd.Timedelta(3.5, 'W')
Out[16]: Timedelta('24 days 12:00:00')
In [17]: pd.Timedelta(3.5, 'microseconds')
Out[17]: Timedelta('0 days 00:00:00.000003500')
In [18]: pd.Timedelta(3, 'microseconds')
Out[18]: Timedelta('0 days 00:00:00.000003') |
Agreed. |
@5j9 Thanks for your correction! It was my oversight not to notice the units of the data. |
I'm new and I wanna solve this issue, but my pre-commit.ci - pr was failed because of cython-lint. Coule anyone please teache me how to deal with it? |
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/dev/reference/api/pandas.Timedelta.html#pandas.Timedelta
Documentation problem
It currently states:
pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 1867 in 2a10e04
There is no
float
.Suggested fix for documentation
Add
float,
to accepted types.There already exists a code branch for
float
values so this should not be a problem:pandas/pandas/_libs/tslibs/timedeltas.pyx
Line 2056 in 2a10e04
The text was updated successfully, but these errors were encountered: