I have the following function in Python (snippet 1):
´Snippet 1:
import eikon as ek #import Eikon module import numpy as np def get_data(identifiers,tr_fields,settings,eikon_id): ek.set_app_id(eikon_id) df = ek.get_data(identifiers, tr_fields,settings)[0] df.columns = df.columns.str.replace(r"[ ]", "_") df.columns = df.columns.str.replace(r"[-]", "_") df = df.fillna(np.nan) return df
If I use it with these parameters (snippet 2), I get the following outcome (image 1):
Snippet 2:
tr_fields=['TR.TotalReturn.calcDate', 'TR.TotalReturn'] sets={'SDate': '03/27/2017', 'EDate': '03/31/2017', 'Frq': 'D'} id='XXXX' instruments=['BP8Y3X2','6071475'] a=get_data(instruments,tr_fields,sets,id)
Image 1:
My guess is that Eikon has some sort of default setting that avoids populating a Dataframe with missing data. But, what if I wanted to have that missing data? For this particular case, I'd like to have all five dates for BP8Y3X2 in the Dataframe, obviously with NaN values in their respective Calc_Date and Total_Return columns.
Is something like this possible?
Thanks in advance for your help.