question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

np.ndarray[object] - Timedelta raises

See original GitHub issue
arr = 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:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jbrockmendelcommented, Jul 24, 2018

how should I go about the fix?

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)

0reactions
illegalnumberscommented, Jul 24, 2018

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…?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found