cannot perform __truediv__ with this index type: DatetimeArray

Viewed 415

What does this error mean? My Date column is in the following format - [datetime64[ns]

one of the post on here states that you: "As the error stated, this happens due to the Date column. If you tried to get the covariance matrix with all other columns, it will work just fine. If you want to use the Date column, you can convert the date to the number of seconds and everything will work just fine"

I am not sure why 1) this error shows and 2) what needs to be done.

Date datetime64[ns] N LN Equity float64 A LN Equity float64 AS LN Equity float64 AV LN Equity float64 BRE LN Equity float64

The error comes when I apply the following:

cov_matrix=df.pct_change().apply(lambda x: np.log(1+x)).cov()
cov_matrix
0 Answers
Related