0

I have a list with 506 stocks symbols: AAPL,MSFT,AMZN,TSLA,FB....

I also have 506 text files with the below format and the file names ADBE.txt

Date,Open,High,Low,Close,Volume,OpenInterest
2021-01-11 09:27,477.91,477.91,477.91,477.91,228,0.0
2021-01-11 09:28,478.055,478.055,478.055,478.055,104,0.0
2021-01-11 09:30,478.38,478.38,478.38,478.38,265,0.0
2021-01-11 09:32,478.42,478.6,478.42,478.6,308,0.0
2021-01-11 09:34,478.71,478.71,478.62,478.62,401,0.0

I would like to create a df with Date and Close price for each symbol, the format as specified below

enter image description here

Joe Ferndz
  • 8,417
  • 2
  • 13
  • 33
bobby666
  • 67
  • 6
  • what have you tried so far? What is the format of the 506 files? is it also csv files and is there a way to distinguish each file and tag them to the stock symbol? You will need to do a loop and read all the files in, then merge the dataframes to create the desired output. More details about the 506 files will help. Also look at https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html and https://stackoverflow.com/questions/26903304/reading-data-from-a-csv-file-in-python – Joe Ferndz Jan 13 '21 at 07:15
  • I was able to draw data for each stock symbol in the list from the data source. The data for each stock symbol is stored under the file name of the symbol with extension .txt. I have shown the format of the file above. All files are within the same timeline with index (Date) and number of rows the same. I need to get to a solution where I create common df with index being common and 'close' column for each symbol is inserted into the df. – bobby666 Jan 13 '21 at 07:50

0 Answers0