“AttributeError: module 'refinitiv.dataplatform.content.search' has no attribute 'Definition'”
Error : response = search.Definition(view=asset_view, top=max, filter=filter_str, select=select_str).get_data(). It says that “AttributeError: module 'refinitiv.dataplatform.content.search' has no attribute 'Definition'”
Code was based on Examples-> Commodities-> Shipping and Shipping assets and utilities shipping.ipynb.
Hello Team client is using this code:
import pandas as pd
import math
import refinitiv.dataplatform as rd
import plotly.express as px
from refinitiv.dataplatform.content import search
select = "RIC, AssetName, Latitude, Longitude, OriginPort, DestinationPort, LocationDestination, LocationETA, LocationDraft, HullType"
port = 'Cristobal'
def discover_vessels_arriving_at_port(port_name='', select_str="RIC, AssetName, Latitude, Longitude",
asset_view=search.SearchViews.VesselPhysicalAssets, max=50):
filter_str = f"DestinationPort eq '{port_name}'"
response = search.Definition(view=asset_view, top=max,
filter=filter_str, select=select_str).get_data()
vessels_to_port_df = response.data.df
vessels_to_port_df.dropna(subset=['LocationETA'], inplace=True)
vessels_to_port_df['ETA_Date'] = vessels_to_port_df['LocationETA'].apply(lambda x: x.split('T')[0])
return vessels_to_port_df
x = discover_vessels_arriving_at_port(port, select, max=500)
this code in codebook "asset_view=search.Views.VESSEL_PHYSICAL_ASSETS"
what i need to run as"asset_view=search.SearchViews.VesselPhysicalAssets"
the function discover_vessels need to run
Best Answer
-
Hi @marceugene.belen, may I ask which vessels CodeBook examples you are referring to?
Is it "__Examples__/01. Data Retrieval and Discovery/01.01. Refinitiv Data Library/Access__Search.ipynb"?
Please note that the module 'refinitiv.dataplatform.content.search' has indeed no attribute 'Definition'; you can instead use lines such as, for example:import refinitiv.data as rd
rd.open_session()
rd.discovery.search(
view = rd.discovery.Views.EQUITY_QUOTES,
top = 10,
filter = "( SearchAllCategoryv2 eq 'Equities' and (AvgVol5D gt 2000000 and ExchangeName xeq 'NYSE Consolidated'))",
select = "DTSubjectName,ExchangeName,RIC,IssueISIN,Gics,AssetState,BusinessEntity,PI,SearchAllCategoryv3,SearchAllCategoryv2,SearchAllCategory,TickerSymbol,CUSIP,CinCUSIP,AvgVol5D,RCSCurrencyLeaf,RCSTRBC2012Leaf,ExDividendDate,AvgVol30D,AvgVol90D,MktCapCompanyUsd,Pe,OpProfitUsd",
order_by = "AvgVol5D desc")0
Answers
-
Hi Jonathan! This is the path that Marc is referring to __Examples__/06. Commodities Research/06.03. Shipping/Shipping_Assets_Quickstart.ipynb
0 -
Hi @marceugene.belen, I ran the CodeBook example with no issue... I'm not sure I understand which part you might be stuck on in that example:
0 -
Hello @jonathan.legrand thank you for the response. Will have a call with client and advise him to check this post thread. Client may add more information regarding his error. Thanks for the help.0
-
Code was based on Examples-> Commodities-> Shipping and Shipping assets and utilities shipping.ipynb.
Hello Team client is using this code:
import pandas as pd
import math
import refinitiv.dataplatform as rd
import plotly.express as px
from refinitiv.dataplatform.content import search
select = "RIC, AssetName, Latitude, Longitude, OriginPort, DestinationPort, LocationDestination, LocationETA, LocationDraft, HullType"
port = 'Cristobal'
def discover_vessels_arriving_at_port(port_name='', select_str="RIC, AssetName, Latitude, Longitude",
asset_view=search.SearchViews.VesselPhysicalAssets, max=50):
filter_str = f"DestinationPort eq '{port_name}'"
response = search.Definition(view=asset_view, top=max,
filter=filter_str, select=select_str).get_data()
vessels_to_port_df = response.data.df
vessels_to_port_df.dropna(subset=['LocationETA'], inplace=True)
vessels_to_port_df['ETA_Date'] = vessels_to_port_df['LocationETA'].apply(lambda x: x.split('T')[0])
return vessels_to_port_df
x = discover_vessels_arriving_at_port(port, select, max=500)this code in codebook "asset_view=search.Views.VESSEL_PHYSICAL_ASSETS"
what i need to run as"asset_view=search.SearchViews.VesselPhysicalAssets"
the function discover_vessels need to run
0 -
Hi @marceugene.belen , If i understand correctly, we are speaking about
"__Examples__/06. Commodities Research/06.03. Shipping/Shipping_Assets_Quickstart.ipynb"Please note that this example, in Codebook, has been updated and now uses the new and improved (free to install) Refinitiv Data Library for Python within the helper file :
"__Examples__/06. Commodities Research/06.03. Shipping/_utilities_shipping.ipynb"
As per that file, please do not run the linefrom refinitiv.dataplatform.content import search
Instead, please run the linefrom refinitiv.data.content import search
0 -
When client types in
from refinitiv.data.content import search
the code autosuggest dataplatform so client needs to just type it using data.content dataplatform?
Also is there anything else that we need to change in the code of client in order to run it?
0 -
May I ask what code should I edit?
0 -
Hi @marceugene.belen , As per our call, let's call the client together.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 中文论坛