question

Upvotes
Accepted
54 1 0 5

Workspace Python API get_data does not sort and filter as expected

When using Workspace Python API under Windows 10, the following commands do not sort and filter the results as required:


Fields=['TR.DealTarget', 'TR.DealAcquiror', 'TR.DealStatus', 'TR.DealDate', 'TR.DealType', 'TR.DealPercentSought/100', 'TR.DealValueAnnounced/1000000', 'TR.DealCurrency']

df=rd.get_data('NOVOb.CO', Fields, parameters={'StartNum':1,'EndNum':3,'SortD':'TR.DealDate','SortOrder':'Descending','NULL':'Blank','SDate':'FY-10','Edate':'FY3'})


According to the parameters, the command should sort by Date descending, and return the first 3 rows. Instead, the results are returned as sorted by Date ascending, with 8 rows in total.


How can the required results be returned?

#contentpython api
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
84.6k 287 53 77

@IoannisG

Thank you for reaching out to us.

I checked those fields on the Data Item Browser and found that those fields may not support the StartNum and EndNum parameters.

1720155843799.png

However, please contact the helpdesk team direclty via MyAccount to confirm this.


1720155843799.png (42.0 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.

Upvote
15.3k 32 5 10

Hi @IoannisG ,

As an alternative, you can use the python code to returned the first 3 rows after sorting by date descending.

For example

df.sort_values(by='Date', ascending = False, inplace = True) 
df.head(3)

1720160908704.png


1720160908704.png (54.1 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.

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.