np.ndarray[object] - Timedelta raises
See original GitHub issuearr = np.array([pd.Timestamp.now(), pd.Timedelta('2D')])
>>> arr - pd.Timedelta('1D')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'numpy.ndarray' and 'Timedelta'
It should attempt to operate element-wise.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
extracting days from a numpy.timedelta64 value - Stack Overflow
You can convert it to a timedelta with a day precision. To extract the integer value of days you divide it with a...
Read more >Datetimes and Timedeltas — NumPy v1.24 Manual
This behaviour is deprecated and will raise an error in the future. Datetime and Timedelta Arithmetic#. NumPy allows the subtraction of two datetime...
Read more >Chapter 9: Advanced Data Wrangling With Pandas
We've seen how libraries like NumPy and Pandas can vectorise operations for ... 2 x.upper() AttributeError: 'numpy.ndarray' object has no attribute 'upper'
Read more >datetimelike.py
_ndarray: np.ndarray @cache_readonly def _can_hold_na(self) -> bool: return True ... _unbox_scalar(Timedelta("10s")) # doctest: +SKIP 10000000000 """ raise ...
Read more >typeerror: unsupported operand type(s) for : 'timedelta' and 'str'
from datetime import datetime, timedelta start = "2019-09-01" end = "2019-09-10" # Convert ... pandas-dev/pandasnp.ndarray[object] - Timedelta raises#21980.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Take a look at the code block Joris quoted above. At the moment that lets ‘m’ and ‘M’ dtypes through but stops everything else. The fix will involve letting ‘o’ dtypes through (and making sure they are handled correctly)
Ah! 🤦♂️ yea I missed that part in the example. I repro’d the bug with that on master and latest pip. So with this then how should I go about the fix? It’s not operating element wise on the array because the timedeltas.pyx isn’t returning that it is a timedelta correctly? or…?