Context: I have a tickerlist which is defined like :
"CN:QJCH,CN:WAPH,III,U:MMM,DK:DSA,DK:DSB,K:AACA,W:SAGB,IN:AB,S:ABBN, and so on…. about 3200 tickers
all_batches_gmrgn1 = []
batch_size = 5
field_list1 = [
"GRM1MN", "GRM2MN", "GRM3MN",
"X(IBP)/X(BPS1MN)", "X(IBP)/X(BPS2MN)", "X(IBP)/X(BPS3MN)",
"X(EVT1MN)/X(SAL1MN)", "X(EVT2MN)/X(SAL2MN)", "X(EVT3MN)/X(SAL3MN)",
"X(IBP)/X(EPS1MN)", "X(IBP)/X(EPS2MN)", "X(IBP)/X(EPS3MN)",
"X(DPS1MN)/X(IBP)*100.00", "X(DPS2MN)/X(IBP)*100.00", "X(DPS3MN)/X(IBP)*100.00",
"ROE1MN", "ROE2MN", "ROE3MN"
]
total_batches = len(tickerlist) / batch_size
for i in range(0, len(tickerlist), batch_size):
batch_number = i // batch_size + 1
batch_list = tickerlist[i:i + batch_size]
batch_str = ", ".join(batch_list)
batch_str_quoted = f'"{batch_str}"'
try:
df = ds.get_data(
tickers=batch_str_quoted,
fields=field_list1,
kind=0
)
df.drop('Currency', axis=1, inplace=True, errors='ignore')
all_batches_gmrgn1.append(df)
print(f" Processed batch {batch_number} out of {total_batches}")
except Exception as e:
print(f" Error in batch {batch_number} out of {total_batches}: {e}")
Combine all processed data
gmrgn1_combined = pd.concat(all_batches_gmrgn1)
gmrgn1_combined
Output received is: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
"CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM1MN | Index was out of range. Must be non-negative a... |
---|
1 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM2MN | Index was out of range. Must be non-negative a... |
---|
2 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM3MN | Index was out of range. Must be non-negative a... |
---|
3 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | X(IBP)/X(BPS1MN) | Index was out of range. Must be non-negative a... |
---|
4 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | X(IBP)/X(BPS2MN) | Index was out of range. Must be non-negative a... |
---|
Can You please check why