question

Upvotes
Accepted
1 1 1 2

Finding data with longest time series within a series of RICS // Searching for NaTs

If i had a query such as

response=search.Definition(
    filter = f"RCSUnderlyingProductName eq 'Corn' and ExchangeName eq 'GeoGrain' and DTSubjectName eq 'Ohio'",
    order_by = "ExpiryDate desc",
    top = 10000,
    select = "DTSubjectName, ExchangeName, RIC, RCSAssetCategoryLeaf, AssetState, ExpiryDate, UnderlyingQuoteRIC, FirstNoticeDay",
).get_data()
geograin_df  = response.data.df

to find GeoGrain RICs - but wanted to narrow it down by the first available date, is there some synatax that could be used to filter at this level.

Additionally in the above expression, I would like to filter the data for those without ExpiryDate (that is that return NaT (not a time)) - but cannot seem to work out what string or phrase to work with.

Apologies as my SQL is quite poor!

Cheers!

pythonrdp
icon clock
10 |1500

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

Upvote
Accepted
7.2k 18 2 8

Dear @Shadeun ,


In order to get data for those without ExpiryDate, I would advice consider filtering by AssetState eq 'AC' instead since ExpiryDate eq 'NaT' return a type error. This would hopefully resolve your second query as NaTs are active assets. As it comes to the first one, you would need to find the respective property name first and then think of a syntax for filtering.


To find a possible property for your case I would advice using browser.properties() function specified in this article.


Hope this was helpful and feel free to let me know if you have any further question.


Best regards,

Haykaz

icon clock
10 |1500

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

Upvotes
15.4k 32 5 10

hi @Shadeun ,

isnull and notnull work with NaT so you can handle them much the same way you handle NaNs. For example,

geograin_df[geograin_df['ExpiryDate'].notnull()]

1658896604031.png

Regarding the filtering on first available date, let me try to check and will keep you updated


1658896604031.png (97.7 KiB)
icon clock
10 |1500

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

Thanks, I should've been more specific that I was looking for a way to write it into the filter string rather than the pandas way (which is fine, its just that putting in the general string helps reduce results below the 10k threshold)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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