-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DEPR: Deprecate pandas.datetime #30489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
c2a93c3
6d47e44
0329d24
b45a47d
624f2de
bf95eef
342038f
7dfce82
54ce63e
ba8cbb0
5e9a97b
a133d1b
e3b6fcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,6 @@ | |
"the C extensions first." | ||
) | ||
|
||
from datetime import datetime | ||
|
||
from pandas._config import ( | ||
get_option, | ||
set_option, | ||
|
@@ -210,6 +208,19 @@ class Panel: | |
|
||
return Panel | ||
|
||
elif name == "datetime": | ||
warnings.warn( | ||
"The pandas.datetime module is deprecated " | ||
ryankarlos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"and will be removed from pandas in a future version. " | ||
"Import datetime directly instead.", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
|
||
from datetime import datetime as dt | ||
|
||
return dt | ||
|
||
elif name == "np": | ||
|
||
warnings.warn( | ||
|
@@ -264,13 +275,39 @@ def __getattr__(self, item): | |
FutureWarning, | ||
stacklevel=2, | ||
) | ||
|
||
try: | ||
return getattr(self.np, item) | ||
except AttributeError: | ||
raise AttributeError(f"module numpy has no attribute {item}") | ||
|
||
np = __numpy() | ||
|
||
class __Datetime: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why two underscores instead of one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just to make it consistent with how __numpy() was being used - same for get__attr as thats how its used in |
||
def __init__(self): | ||
from datetime import datetime as dt | ||
import warnings | ||
|
||
self.datetime = dt | ||
self.warnings = warnings | ||
|
||
def __getattr__(self, item): | ||
self.warnings.warn( | ||
"The pandas.datetime module is deprecated " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as before |
||
"and will be removed from pandas in a future version. " | ||
"Import datetime directly instead", | ||
FutureWarning, | ||
stacklevel=2, | ||
) | ||
|
||
try: | ||
return getattr(self.datetime, item) | ||
except AttributeError: | ||
raise AttributeError(f"module datetime has no attribute {item}") | ||
|
||
datetime = __Datetime().datetime | ||
|
||
|
||
# module level doc-string | ||
__doc__ = """ | ||
pandas - a powerful data analysis and manipulation library for Python | ||
|
Uh oh!
There was an error while loading. Please reload this page.