Summary: datetime
(from the Python Standard Libary) was never really a part of Pandas or its API, which the developers are now making a concerted effort to warn about. You can access the datetime
class directly:
from datetime import datetime
Detail: Older versions of Pandas (example: 0.20) contained:
from datetime import datetime
in pandas/__init__.py
This meant that, if you really wanted to, you could reference and use pd.datetime
, which is really just the standard library's datetime class.
Per Pandas issue #30610 and issue #30296, pandas.datetime
is really just standard datetime.datetime
. It looks like deprecating them (which, interesting, is done via overriding __getattr__
at the module level*), is done to discourage "roundabout usage" where other 3rd party libraries/modules are brought into the top-level Pandas namespace.
That is, the Pandas library doesn't consider datetime
(or numpy
) being available in that namespace to be a part of its API, so you shouldn't depend on it being there in the first place.
*Specifically, this looks like:
# pandas/__init__.py
def __getattr__(name):
import warnings
elif name == "datetime":
warnings.warn(...)
from datetime import datetime as dt
return dt