Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unexpected output
#1
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.
metulburr write Oct-24-2020, 03:55 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unexpected output Starter 2 495 Nov-22-2023, 12:08 AM
Last Post: Starter
  Unexpected Output - Python Dataframes: Filtering based on Overlapping Dates Xensor 5 722 Nov-15-2023, 06:54 PM
Last Post: deanhystad
  Unexpected output while using random.randint with def terickson2367 1 520 Oct-24-2023, 05:56 AM
Last Post: buran
  Unexpected output from df.loc when indexing by label idratherbecoding 6 1,211 Apr-19-2023, 12:11 AM
Last Post: deanhystad
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,061 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Unexpected output palladium 4 2,761 Jan-11-2020, 03:26 PM
Last Post: palladium
  Unexpected output: if statement CabbageMan 1 1,771 Sep-04-2019, 04:12 PM
Last Post: ThomasL
  Unexpected Output using classes and inheritance langley 2 1,958 Jul-04-2019, 09:33 AM
Last Post: langley
  float multiplication - unexpected output inesk 3 3,360 Dec-11-2018, 10:59 AM
Last Post: DeaD_EyE
  Unexpected output when searching for a string from os.popen output FujiJean 3 3,088 Oct-02-2018, 11:39 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020