-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: TypeError("type Timedelta doesn't define __round__ method") #58071
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
Comments
Does the documentation say that |
yes it can @Aloqeely :) Yet, I find it weird to crash on a simple round() when the library think about doing serie.round() ! |
When reading code, I do not think it is clear what |
I believe the suggestion was to have a default behavior for Python's |
Perfect reformulation @Aloqeely :) For the "should we do it ?" I would say seconds is a logical default choice. And we like default behavior in python even if we all prefer specific precision, it's always appreciable to make code work in a really short way. For the 'how to do it ?" I would just Override the round method as I did on my custom class (and so I won't have to do it in my project and the future projects but the library would handle it). But it's maybe too simple and I miss side effects ? Should I propose a pull request ? |
Based on discussion in #58081 can we close this as no-action? |
Yeah thanks for the suggestion but closing |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
I try to round the value, actually I want to round for the seconds. I was surprised to see that there are no default round method ?
Best use of round would be to precise the type of round (day/seconds/...) but I think it should have a default behavior.
In a pythonic way.
And I think seconds should be the default.
Expected Behavior
It should have a default behavior, in a pythonic way. I propose seconds for the default.
Installed Versions
INSTALLED VERSIONS
commit : fd3f571
python : 3.9.19.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-19041-Microsoft
Version : #3996-Microsoft Thu Jan 18 16:36:00 PST 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_FR.UTF-8
LOCALE : fr_FR.UTF-8
pandas : 2.2.0
numpy : 1.26.3
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 69.2.0
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.1.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.3
IPython : 8.18.1
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.8.2
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.12.0
sqlalchemy : 2.0.28
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: