Closed jreback closed 5 years ago
cc @TomAugspurger @jbrockmendel
To clarify, DatetimeArray._data
is always an M8[ns] ndarray. The constructor accepts either integer or datetime64[ns] values.
In [6]: pd.arrays.DatetimeArray(np.array([1, 2]))._data
Out[6]:
array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002'],
dtype='datetime64[ns]')
In [7]: pd.arrays.DatetimeArray(np.array([1, 2], dtype='M8[ns]'))._data
Out[7]:
array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002'],
dtype='datetime64[ns]')
oh ok, its just sometimes _simple_new is getting i8 and sometimes M8[ns], worth making that consistent? (e.g. having the caller do that)
No, it’s allowed specifically so code can be shared by timedelta/datetime/period
@jreback did tom’s comment clarify this sufficiently?
i understand what is going on but it’s a pretty odd calling convention
meaning that the caller should guarantee that the input is of the appropriate type
meaning that the caller should guarantee that the input is of the appropriate type
OK then we're back to me response: the convention exists as it does so that DTA/TDA/PA can share code.
This is correct as is. Closing.
seems we have DTA's holding i8 OR M8[ns], see: xref https://github.com/pandas-dev/pandas/pull/24686/files
This is really really odd, and we should not allow this, always converting to i8.