Using fundamental_and_reference leads to warning when <NA> values are in the result

I tried to get some data using lseg-data 2.0.1 with "fundamental_and_reference".

The result obviously contains some <NA> values.

I got the message:
"FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set pd.set_option('future.no_silent_downcasting', True)"

This is my program:

asofdate = "2024-12-13"
asofdate = str(asofdate)
curn = "EUR"
constituents1_list = ["AAK.ST","AALB.AS", "WTB.L", "ZALG.DE", "ZURN.S"]
retr_fields = ['TR.CommonName', 'TR.TotalAssetsReported(Period=FY0,scale=6,IncludePartial=No)',                'TR.LTInvestments(Period=FY0,scale=6,IncludePartial=No)', 'TR.STInvestments(Period=FY0,scale=6,IncludePartial=No)']
# assign the values for the retrieval parameters
retr_param = {'SDate':f'{asofdate}', 'curn':f'{curn}'}
###   open the session
ld.open_session(name='platform.ldp')
print("*** LSEG-Session opened ...")
response = fundamental_and_reference.Definition(    universe=constituents1_list,    fields=retr_fields,    parameters=retr_param).get_data()
universe1 = response.data.df
print("universe1:")
print(universe1)

And this is the result:

image.png

What can I do in order to avoid the FutureWarning and use correct code?

Best Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @Torben2

    Thank you for reaching out to us.

    I checked and found that this FutureWarning message was added in Pandas 2.2.0. However, the LSEG Data LIbrary also supports the older Pandas versions (from pandas<3.0.0,>=1.3.5). This means that the library should run fine with the supported Pandas versions.

    You can suppress this warning message with the following code.

    import pandas as pd
    pd.set_option('future.no_silent_downcasting', True)
    
    response.data.df
    
  • Torben2
    Torben2 Newcomer
    Answer ✓

    Thanks for the answer. It works well with this addition.