79250422

Date: 2024-12-04 08:52:00
Score: 1
Natty:
Report link

I have managed to resolve this issue. The reason for the error is very simple -

  1. I had to remove 'i' from "res = getHistoricalData(symboldf.iloc[i])" to make it "res = getHistoricalData(symboldf.loc[i])". This will solve the issue.

    candledfList = [] for i in symboldf.index[:-1]: candledfList = [] res = getHistoricalData(symboldf.iloc[i]) if res is not None: candledfList.append(res) finalDataDf = pd.concat(candledfList, ignore_index=True)

  2. The for loop below is to generate single/separate file for each company stock data. We can remove this and move the logic to for loop above this and generate one single CSV file to capture all companies data. But the problem with this approach is we will lose data for several companies, not sure why. I lost 36 companies data when tried to capture all companies data into one single CSV file.

isCsv = True for symData in candledfList[:-1]: try: filename = symData.iloc[0]['symbol'] if isCsv: filename = f'{filename}.csv' symData.to_csv(folder + filename, index=False) del candledfList else: filename = f'{filename}.parquet' symData.to_parquet(folder_parquet + filename, engine='pyarrow') del candledfList except Exception as e: print(f'Error {e}')

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: NeedBasedLearner