2

When trying to run a FamaMacBeth regression on my dataset, I get the TypeError:

cannot astype a datetimelike from [datetime64[ns]] to [float64],

My date column is of type numpy.ndarray

Anyone know what I am doing wrong?

iacob
  • 20,084
  • 6
  • 92
  • 119
Pythonist
  • 48
  • 2
  • 7

1 Answers1

1

This is a known issue:

The problem is that we don't support the datetime64[s] type on pandas objects, even though it's a valid type for NumPy arrays.

A possible workaround is converting directly to float, as in the comment on this question:

Pandas DataFrame - 'cannot astype a datetimelike from [datetime64[ns]] to [float64]' when using ols/linear regression

iacob
  • 20,084
  • 6
  • 92
  • 119