For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

Error Message "Shape of passed values is (24, 2), indices imply (22, 2)" .

Hi, I want to get timeseries data for a list of 300 rics. I found some rics in the list return error message as mentioned in the question. For example, 'USD1MD=EU', 'USD1MD=EQBK'. If I get the timeseries for each Ric individually, each ric works. But if I put both rics together in a list, they return error message. I know the length of the data returned from the two Rics are different. Is there a solution to get the data with 1 single list of all the rics? I want to get the same timeseries data with a list of 300 rics.

Below is the data I want to get and it didn't work.

data_both = ek.get_timeseries(['USD1MD=EU', 'USD1MD=EQBK'],start_date='2021-01-01',end_date='2021-01-31',fields='CLOSE')


Below is what I used to get the data individually and it works perfectly for each ric

data_individual = ek.get_timeseries(['USD1MD=EQBK'],start_date='2021-01-01',end_date='2021-01-31',fields='CLOSE')

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

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

Upvotes
Accepted
18k 21 12 20

The specialist updates the ticket 09661076 as the following:

The problem you are encountering is related to the different shapes of the resulting dataframes. This is one of the limitations of the method, ek.get_timeseries, therefore normally I would advise going with the ek.get_data() method, BUT for this specific example, we have an issue with USD1MD=EQBK, which lacks the correct TR fields. The syntax for the second instrument will look like this:

df,err = ek.get_data(instruments = ['USD1MD='], fields = ['TR.BIDPRICE', 'TR.BIDPRICE.date'], parameters = {'SDate':'20210101', 'EDate':'20210225'})

df


But for your problem, I figured out a workaround. It requires some work on adjusting the time series, but the result looks ok.

Try this code:


first = ek.get_timeseries(['USD1MD=EQBK'], start_date='2021-01-01', end_date='2021-01-31', fields='CLOSE', raw_output=False)
second = ek.get_timeseries(['USD1MD=EU'], start_date='2021-01-01', end_date='2021-01-31', fields='CLOSE', raw_output=False)

first = first.reset_index()
first['Date'] = first['Date'].drop_duplicates()
first = first.dropna()
first = first.set_index('Date')

first = first.asfreq('D',method = 'bfill')
second = second.asfreq('D', method = 'bfill')

combined = pd.merge(first, second)
combined


icon clock
10 |1500

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

Upvotes
18k 21 12 20

Hi @anni.wang

I submitted ticket no. 09661076 on your behalf.

A support team will contact you about the issue.


These 2 codes work fine:


But when combining the instruments, the API could not handle the returning data.

(The request is valid, API receives response from the backend)


ahs1.png (19.1 KiB)
ahs2.png (148.8 KiB)
icon clock
10 |1500

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

Upvotes
1 0 0 0

Hi, since I need to do a 1000 rics, the above code didn't work but you have pointed out the problem. I built a For loop to get the data one at a time for each Ric. However, I had some new issues. A lot of the rics not returning data. However if I search the rics in reuters, they do come up with data. For example USD1MD=UBTA, USD1MD=HVBG return error messages. Some rics do work well in the code below. For example USD1MD=LOYL, USD1MD=VBAH work well

See my code below and error message below.

The ContributorRics ['1M'] includes the rics mentioned above and the ones shown in the error message below.

code:

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

ric_dict=dict()

for ric in ContributorRics['1M']:

try:

data_sr = ek.get_timeseries(ric,start_date='2021-02-01',end_date='2021-03-2',fields='CLOSE').squeeze()

data_sr = data_sr.drop_duplicates()

ric_dict[ric]=data_df

except:

print(ric)

print("Unexpected error:", sys.exc_info()[0])

continue

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


Below is the list of Rics that returns errors: USD1MD=UBTA, USD1MD=HVBG etc

USD1MD=BOGF Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=UBTA Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=LBWX Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=HVBG Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=BERA Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=NDEA Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=DGZF Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=BILX Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=BUMZ Unexpected error: <class 'AttributeError'> USD1MD=FBIT Unexpected error: <class 'AttributeError'> USD1MD=BIIA Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=SCNN Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=STKN Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=SCGH Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=SCCI Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=VIBD Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=SCGM Unexpected error: <class 'eikon.eikonError.EikonError'> USD1MD=NXIP Unexpected error: <class 'AttributeError'> USD1MD=ALFT Unexpected error: <class 'AttributeError'> USD1MD=ACLB Unexpected error: <class 'eikon.eikonError.EikonError'> EUR1MD=BOGF Unexpected error: <class 'eikon.eikonError.EikonError'> EUR1MD=VBAH Unexpected error: <class 'eikon.eikonError.EikonError'> EUR1MD=KBCB Unexpected error: <class 'eikon.eikonError.EikonError'>
icon clock
10 |1500

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

Hi @anni.wang

I saw that Zoya already pointed out the issue with invalid RIC or other error at https://community.developers.refinitiv.com/questions/74268/error-message-for-some-rics-but-not-the-others.html

Click below to post an Idea Post Idea