0

I imported the data for the monthly returns for SNP and GME. I also downloaded the 3 month TBill rate from FRED. I am trying to create a dataframe table that includes SNP, GME, and TBill. When I try running the code, the FRED data has a timestamp in addition to the date. Format is 2012-05-01 00:00:00. The data from yahoofinancials is just 2012-05-01. How do I remove the timestampe from the FRED data?

how I combined SNP and GME:

#Construct one dataframe named monthly_ret2 to store the return series
monthly_ret2 = pd.concat([SP500_monthly_returns, GME_monthly_returns], axis=1)

Downloaded data from FRED

#Download 3-Month Treasury Bill rate from Fred
tbill = fred.get_series('TB3MS', observation_start='2004-01-01', observation_end='2019-12-31')

Dropping Null

#Dropping all null observations and store the result into the 'clean_monthly_ret2'
tbill_ret = tbill_ret.dropna()
monthly_ret2 = monthly_ret2.dropna()
#Adding data returns of Tbill columnn into monthly_ret2
monthly_ret2['TBill'] = tbill_ret

When I switch it around it either shows the SNP/ GME as NAN and shows TBill OR it shows SNP/ GME and shows TBill as NAN.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • just use `pd.to_datetime` to normalize the time columns as actual datetime objects. please try to generalize your question when asking on stack overflow - there's nothing specific to financial data that makes merging data special. this question has lots of similar answers out there :) – Michael Delgado Oct 27 '22 at 00:12
  • Does this answer your question? [Pandas merge on \`datetime\` or \`datetime\` in \`datetimeIndex\`](https://stackoverflow.com/questions/51755268/pandas-merge-on-datetime-or-datetime-in-datetimeindex) – Michael Delgado Oct 27 '22 at 00:14
  • Thank you @MichaelDelgado. I am new to Stack overflow and python. I will read through what you provided. – SSI_Guy Oct 27 '22 at 00:23

0 Answers0