“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

  • [Deleted User]
    [Deleted User] Newcomer
    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")

Answers