New posts are disabled while we improve the user experience.

You can browse the site, or for urgent issues, raise a query at MyAccount.

question

Upvotes
54 3 5 14

Why do I face with the following error: [NaT] not found in axis?

Please find Traceback below:


---------------------------------------------------------------------------

KeyError Traceback (most recent call last)

~\AppData\Local\Temp/ipykernel_26288/1078268507.py in <module>

1 rd.open_session()

2

----> 3 data = rd.get_history(universe=['4295856055', '4295856249', '4295856359', '4295856557', '4295857081'],

4 fields=['TR.RevenueActSurprise(Period=FQ0,Frq=FQ)'],

5 interval='1D', start='2005-01-01', end='2022-04-20')


~\anaconda3\lib\site-packages\refinitiv\data\_data\fin_coder_layer\get_history.py in get_history(universe, fields, interval, start, end, adjustments, count)

120 }

121

--> 122 return _get_history(

123 p_events=_pricing_events,

124 p_summaries=_pricing_summaries,


~\anaconda3\lib\site-packages\refinitiv\data\_data\fin_coder_layer\get_history.py in _get_history(p_events, p_summaries, adc, params)

168 if adc_fields:

169 adc_default_df = _create_default_df(universe, adc_fields)

--> 170 adc_df = _send_request(

171 data_provider=adc,

172 params={


~\anaconda3\lib\site-packages\refinitiv\data\_data\fin_coder_layer\get_data.py in _send_request(data_provider, params, logger, default_df)

191 # this check can be removed after all API would return

192 # dataframe in response or raise exception

--> 193 if response.data.df is not None:

194 df = response.data.df

195 df.flags.exception_event = {"raise_exception": False, "exception": None}


~\anaconda3\lib\site-packages\refinitiv\data\_data\content\fundamental\_data_provider.py in df(self)

29 def df(self):

30 if self._dataframe is None and self._raw:

---> 31 self._dataframe = self._dfbuilder(self._raw, self._use_field)

32

33 return self._dataframe


~\anaconda3\lib\site-packages\refinitiv\data\_data\content\fundamental\_df_builder.py in build_date_as_index(self, content_data, use_field_names_in_headers)

166 ) -> pd.DataFrame:

167 df = self.build_index(content_data, use_field_names_in_headers)

--> 168 df = set_date_as_index(

169 self.headers, df, use_field_names_in_headers, self.auto_headers

170 )


~\anaconda3\lib\site-packages\refinitiv\data\_data\content\fundamental\_df_builder.py in set_date_as_index(content_headers, df, use_field_names_in_headers, auto_headers)

120 nats.append(idx)

121

--> 122 result.drop(nats, inplace=True)

123 result.sort_index(ascending=False, inplace=True)

124 result.fillna(pd.NA, inplace=True)


~\anaconda3\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)

309 stacklevel=stacklevel,

310 )

--> 311 return func(*args, **kwargs)

312

313 return wrapper


~\anaconda3\lib\site-packages\pandas\core\frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)

4904 weight 1.0 0.8

4905 """

-> 4906 return super().drop(

4907 labels=labels,

4908 axis=axis,


~\anaconda3\lib\site-packages\pandas\core\generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)

4148 for axis, labels in axes.items():

4149 if labels is not None:

-> 4150 obj = obj._drop_axis(labels, axis, level=level, errors=errors)

4151

4152 if inplace:


~\anaconda3\lib\site-packages\pandas\core\generic.py in _drop_axis(self, labels, axis, level, errors)

4212 labels_missing = (axis.get_indexer_for(labels) == -1).any()

4213 if errors == "raise" and labels_missing:

-> 4214 raise KeyError(f"{labels} not found in axis")

4215

4216 slicer = [slice(None)] * self.ndim


KeyError: '[NaT] not found in axis'

eikon-data-apipython
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
7.2k 23 3 6

Hi @alekseenkova.marina, May I ask what session you are using with the RD library? This is configured in this file which you ought to point to with your code.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

To be honest, I do not understand what I should send you.
Hi @alekseenkova.marina, Would you mind showing us the code you used that got you this error? Please remove any passwords or usernames when sharing this.


May I also ask: did you try your code in CodeBook?

Upvotes
28k 68 18 14

Hello @alekseenkova.marina

I cannot replicate this issue (and other issues) with version 1.0.0b9.

You can see my replication detail on this https://community.developers.refinitiv.com/questions/95875/why-do-i-face-with-the-memory-error.html post.

Hope this helps.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.