I have a ~14,000 row dataframe and attempting to fill in some data into a new column by calling an API. The code below retrieves the expected response, however, it seems each iteration waits for a response to go to the next row.
Here is the function:
def market_sector_des(isin):
isin = '/isin/' + isin
return blp.bdp(tickers = isin, flds = ['market_sector_des']).iloc[0]
I am using xbbg to call the Bloomberg API.
The .apply() function returns the expected response,
df['new_column'] = df['ISIN'].apply(market_sector_des)
but each response takes around 2 seconds, which at 14,000 lines is roughly 8 hours.
Is there any way to make this apply function asynchronous so that all requests are sent in parallel? I have seen dask as an alternative, however, I am running into issues using that as well.