But if you really need to convert, just use astype like you would for any other conversion: The error seems to occur when running. However, on a big endian machine, np.dtype('datetime64[ns]') would equal np.dtype('>m8[ns]').
Cannot cast array data from dtype(‘<M8[ns]‘) to dtype(‘float64
Cannot cast array data from dtype('<m8[ns]') to dtype('float64') according to the rule 'safe' i attached here my code.
Pandas series with timestamps internally use the <m8[ns] representation.
Today i stumbled upon the fact that python wrapper for alpha vantage api (alpha_vantage) uses dtype('<m8[ns]') as data type for the index of dataframe, containing output. When creating an array of datetimes from a string, it is still possible to automatically select the unit from the inputs, by using the datetime type with generic units. And how can i work around it? Numpy arrays with datetime64[ns] can be seamlessly used within pandas dataframes.
<m8[ns] または >m8[ns] は、マシンのエンディアン性に依存します。 一般的なdtypesが特定のdtypesにマッピングされる同様の例は他にもたくさんあります。 int64 は. An array of datetimes can be. On a machine whose byte order is little endian, there is no difference between np.dtype('datetime64[ns]') and np.dtype('<m8[ns]'):


![PYTHON Difference between data type 'datetime64[ns]' and ' M8[ns](https://i.ytimg.com/vi/fiiPjHYVrvo/maxresdefault.jpg)
![Cannot cast array data from dtype(‘<M8[ns]‘) to dtype(‘float64](https://i2.wp.com/img-blog.csdnimg.cn/3785234f921440859f2de3b06bb74973.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBARWtrbzI4NQ==,size_20,color_FFFFFF,t_70,g_se,x_16)
![Cannot cast array data from dtype(‘<M8[ns]‘) to dtype(‘float64](https://i2.wp.com/img-blog.csdnimg.cn/66c820acaaeb4669b7b87bcadd2cdfb8.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBARWtrbzI4NQ==,size_20,color_FFFFFF,t_70,g_se,x_16)