Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

Merge Pandas sub dataframes in one sorted by date and add column symbol

$
0
0

I have a number of csv files with stock data and i create a Pandas data frame with a for symbol in symbol list loop by providing the path and reading these files..The data frame has each stock sub data frame separated..

sym_list = ['AAPL','TSLA','GOOG']for symbol in sym_list:    print(symbol)    df = pd.read_csv(fr'--some path--{symbol}.csv')    # this dataframe prints as separated sub frames for each symbol     # the data frame has Date,Open,High and similar Columns of data

I want to add a symbol column to each sub frame,

Merge the 3 sub frames into one continuous final_df ,

Sort the final_df by column ['Date'] .

if anyone can help with this it will be very appreciated!Regards


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>