Python Forum

Full Version: unexpected output
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
def compile_data():
with open("dict.pickle","rb") as f:
tickers = pickle.load(f)

main_df = pd.DataFrame()

for count,ticker in enumerate(tickers):
df = pd.read_csv(r'C:\Users\User\Desktop\StockProject\5 stocks/{}.csv'.format(ticker))
df.set_index('date', inplace=True)

df.rename(columns={'close':ticker}, inplace=True)
df.drop(['no','ticker','name','per','open','high','low','volume','o/i'],1, inplace=True)
if main_df.empty:
main_df = df
else:
main_df = main_df.join(df, how='outer')

print(main_df.head())
main_df.to_csv('lastcombine.csv')

compile_data()
.
.
.
can someone help me with this problem? im trying to combine all 5 stock of historical prices into one but the output was not what am expected it to be. the date and close price went crazy.