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?

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @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.

Answers

  • 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