Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hasanrashid
Copy link
Contributor

@hasanrashid hasanrashid commented Sep 11, 2025

This PR intends to close [ENH]: Support using datetimes as positions argument to violin(...) #30417

It should be possible to set the position of a violin plot to be a datetime. Currently, an attempt to do this results in this error message: TypeError: unsupported operand type(s) for +: 'float' and 'datetime.datetime'

The error stems from trying to perform operations between float and datetime if datetime was provided as position arguments.

The proposed solution improves the error message to be:

"If positions are datetime/date values, pass widths as datetime.timedelta (e.g., datetime.timedelta(days=10)) or numpy.timedelta64.

unit tests are in tests\test_violinplot_datetime.py

I had opened another PR 30508, but messed up the commits while making changes. I am making this one after reading the suggestion here: #30508 (comment) by @rcomer . This change updates the error message instead of converting the position and width

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