ValueError: datetime64/timedelta64 values and dtype must have a unit specified
I'm getting the below behavior when calling get_news_headlines in the python api. I'm running python 3.10.7, and eikon version 1.1.16, windows 11 Pro
Input:
> import eikon as ek
> ek.get_news_headlines('ORDER IMBALANCE', date_from='2022-10-19T00:00:00', date_to='2022-10-19T23:59:59', count=100)
Error:
File "C:\Python310\lib\site-packages\eikon\news_request.py", line 126, in get_news_headlines
return get_data_frame(result)
File "C:\Python310\lib\site-packages\eikon\news_request.py", line 144, in get_data_frame
headlines_dataframe = pd.DataFrame([], numpy.array(first_created, dtype='datetime64'), Headline_Selected_Fields)
File "C:\Python310\lib\site-packages\pandas\core\frame.py", line 770, in __init__
mgr = dict_to_mgr(
File "C:\Python310\lib\site-packages\pandas\core\internals\construction.py", line 451, in dict_to_mgr
index = ensure_index(index)
File "C:\Python310\lib\site-packages\pandas\core\indexes\base.py", line 7371, in ensure_index
return Index._with_infer(index_like, copy=copy)
File "C:\Python310\lib\site-packages\pandas\core\indexes\base.py", line 718, in _with_infer
result = cls(*args, **kwargs)
File "C:\Python310\lib\site-packages\pandas\core\indexes\base.py", line 488, in __new__
result = klass(data, copy=copy, name=name, **kwargs)
File "C:\Python310\lib\site-packages\pandas\core\indexes\datetimes.py", line 360, in __new__
dtarr = DatetimeArray._from_sequence_not_strict(
File "C:\Python310\lib\site-packages\pandas\core\arrays\datetimes.py", line 308, in _from_sequence_not_strict
subarr, tz, inferred_freq = _sequence_to_dt64ns(
File "C:\Python310\lib\site-packages\pandas\core\arrays\datetimes.py", line 2092, in _sequence_to_dt64ns
data = astype_overflowsafe(data, dtype=DT64NS_DTYPE)
File "pandas\_libs\tslibs\np_datetime.pyx", line 288, in pandas._libs.tslibs.np_datetime.astype_overflowsafe
File "pandas\_libs\tslibs\np_datetime.pyx", line 321, in pandas._libs.tslibs.np_datetime.astype_overflowsafe
ValueError: datetime64/timedelta64 values and dtype must have a unit specified
The error is dependent on the data being returned. I do not get this error for headline searches with a different query. Any ideas?
Best Answer
-
Hello @drdan ,
I was not able to reproduce the issue in my local environment or CodeBook, with the same request, at this time, as expect not much time has passed so the result should be close.
It seems from the error that it does not originate with eikon library, rather with one of the eikon dependencies, suspecting numpy or pandas.
Would suggest to verify the versions of pandas and numpy against CodeBook versions:
and if found different, try upgrading to these.
Please let us know how this works on your side?
0
Answers
-
Hi, I am getting the same error code.
Using the below as an example, I believe the error only happens when no headlines were published during the time period specified in the search.
ek.get_news_headlines(query = 'Topic:RTRS Language:LEN ', date_from = '10-Sep-2022 01:00:00', date_to = '10-Sep-2022 01:50:00', count = 100)
This is new. I just went back to some old code that used to work fine.
I am currently using:
Eikon version 1.1.16
Pandas version 1.5.1
Python 3.10.7
Unfortunately I can't say what versions I was using when the code last ran okay.
0 -
Hi @noel.randewich01 ,
I'm sorry to hear that you're facing an issue. However, I was not able to reproduce the issue in my local environment or CodeBook, with the same request.
It seems from the error that it does not originate with the eikon library, but rather with one of the eikon dependencies, suspecting NumPy or pandas.Would suggest verifying the versions of pandas and NumPy against CodeBook versions as mentioned by Zoya in the previous comment
To be of help, below are the current version of the libraries you mentioned in the Codebook app
- Eikon version 1.1.14
- Pandas version 1.3.5
- NumPy version 1.22.4
- Python 3.8.13
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛