• [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] (optional) I have confirmed this bug exists on the master branch of pandas.


import numpy as np
import pandas as pd
pd.Timestamp(np.datetime64('2000-01-01', '10ns')) == pd.Timestamp('2000-01-01')

Should be True, is instead False. The problem is that the unit count of 10 is ignored. Compare:

pd.Timestamp(np.datetime64('2000-01-01', '10ns')).asm8.item()
pd.Timestamp(np.datetime64('2000-01-01', '1ns')).asm8.item()                                        

The bug occurs in two places, both in _libs/tslibs/conversion.pyx. Both get_datetime64_nanos and ensure_datetime64ns forget to check the count. I don't know a Cython API to get the count, though it is accessible from numpy.datetime_data.

Comment From: jbrockmendel

These closed by #61882