Get variable names matched with TR. item names.
Hello,
I'm curious if it's possible to use ek.get_data
or rdp.get_data
functions in a way that returns data items based on the specified fields query (ie starting with 'TR.'), rather than using the default column names.
To provide a concrete example, let's say I have a fields query like this:
df, err = ek.get_data(
instruments = ['AAPL.O'],
fields = [
'TR.ISIN',
'TR.PriceClose',
'TR.PriceClose.date',
'TR.EnvironmentPillarScore',
"TR.AnalyticRenewEnergyUse",
"TR.PercentageGreenProducts",
"TR.BlackorAfricanAmerican-MinoritiesEmployeesPercentage",
"TR.HispanicorLatino-MinoritiesEmployeesPercentage",
"TR.OtherMinoritiesEmployeesPercentage"]
)
I would like to have the variables as they appear in fields, instead of these column names.
df.columns
Index(['Instrument', 'ISIN', 'Price Close', 'Date',
'Environmental Pillar Score', 'Renewable Energy Use Ratio',
'Percentage of Green Products',
'Other - Ethnic Minorities Employees Percentage'],
dtype='object')
The central issue revolves around certain variables not being retrieved as expected. Consequently, the approach of renaming df.columns using the fields list is not a feasible solution.
Is there a method or option that allows me to obtain the data in this format? Your insights would be greatly appreciated. Thank you!
Best Answer
-
Hi @ricardo.henriquez ,
If it could help, check field_name parameter in ek.get_data() function:
get_data(instruments, fields, parameters=None, field_name=False, raw_output=False, debug=False)Set it to True, you'll retrieve a DataFrame with following column headers:
df, err = ek.get_data(
instruments = ['AAPL.O'],
fields = [
'TR.ISIN',
'TR.PriceClose',
'TR.PriceClose.date',
'TR.EnvironmentPillarScore',
"TR.AnalyticRenewEnergyUse",
"TR.PercentageGreenProducts",
"TR.BlackorAfricanAmerican-MinoritiesEmployeesPercentage",
"TR.HispanicorLatino-MinoritiesEmployeesPercentage",
"TR.OtherMinoritiesEmployeesPercentage"],
field_name=True
)
df.columns
Index([
'Instrument',
'TR.ISIN',
'TR.PRICECLOSE',
'TR.PRICECLOSE.DATE',
'TR.ENVIRONMENTPILLARSCORE',
'TR.ANALYTICRENEWENERGYUSE',
'TR.PERCENTAGEGREENPRODUCTS',
'TR.OTHERMINORITIESEMPLOYEESPERCENTAGE'],
dtype='object')3
Answers
-
Thank you for reaching out to us.
I can't any parameter that supports this feature.
You can get the raw output and then rename the field names. After that, re-create a new dataframe from the raw output.
raw_output = ek.get_data(
instruments = ['AAPL.O'],
fields = [
'TR.ISIN',
'TR.PriceClose',
'TR.PriceClose.date',
'TR.EnvironmentPillarScore',
"TR.AnalyticRenewEnergyUse",
"TR.PercentageGreenProducts",
"TR.BlackorAfricanAmerican-MinoritiesEmployeesPercentage",
"TR.HispanicorLatino-MinoritiesEmployeesPercentage",
"TR.OtherMinoritiesEmployeesPercentage"],
raw_output=True
)The output looks like this:
{'columnHeadersCount': 1,
'data': [['AAPL.O',
'US0378331005',
175.01,
'2023-09-15T00:00:00Z',
65.3695219368318,
0.062223362244837,
'',
4.1]],
'headerOrientation': 'horizontal',
'headers': [[{'displayName': 'Instrument'},
{'displayName': 'ISIN', 'field': 'TR.ISIN'},
{'displayName': 'Price Close', 'field': 'TR.PRICECLOSE'},
{'displayName': 'Date', 'field': 'TR.PRICECLOSE.DATE'},
{'displayName': 'Environmental Pillar Score',
'field': 'TR.ENVIRONMENTPILLARSCORE'},
{'displayName': 'Renewable Energy Use Ratio',
'field': 'TR.ANALYTICRENEWENERGYUSE'},
{'displayName': 'Percentage of Green Products',
'field': 'TR.PERCENTAGEGREENPRODUCTS'},
{'displayName': 'Other - Ethnic Minorities Employees Percentage',
'field': 'TR.OTHERMINORITIESEMPLOYEESPERCENTAGE'}]],
'rowHeadersCount': 1,
'totalColumnsCount': 8,
'totalRowsCount': 2}You can map the TR fields to the new names.
0
Categories
- All Categories
- 6 AHS
- 39 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 中文论坛