Pandas DataFrame - 'cannot astype a datetimelike from [datetime64[ns]] to [float64]' when using ols/linear regression
<p>I have a DataFrame as follows:</p>

<pre><code>   Ticker        Date  Close
0    ADBE  2016-02-16  78.88
1    ADBE  2016-02-17  81.85
2    ADBE  2016-02-18  80.53
3    ADBE  2016-02-19  80.87
4    ADBE  2016-02-22  83.80
5    ADBE  2016-02-23  83.07
</code></pre>

<p>...and so on. The <code>Date</code> column is the issue. I'm trying to get the linear regression of the <code>Date</code> column with the <code>Close</code> column:</p>

<pre><code>ols1 = pd.ols(y=ADBE['Close'], x=ADBE['Date'], intercept=True)
</code></pre>

<p>I get the following error:</p>

<pre><code>TypeError: cannot astype a datetimelike from [datetime64[ns]] to [float64]
</code></pre>

<p>I've tried multiple ways of getting rid of this error, for examples:</p>

<pre><code>dates_input = ADBE['Date'].values.astype('datetime64[D]')

dates_input = ADBE['Date'].values.astype('float')
</code></pre>

<p>The second <code>dates_input</code> attempt returns the type as <code>pandas.core.series.Series</code> but I still get an error message.</p>

<p>Does anyone know how to get the <code>Date</code> column to work and get rid of this TypeError?</p>