Skip to content

Commit 407a415

Browse files
committed
deprecation tslib
1 parent eaa9472 commit 407a415

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

doc/source/whatsnew/v0.20.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ If indicated, a deprecation warning will be issued if you reference that module.
461461
"pandas.json", "pandas.io.json.libjson", "X"
462462
"pandas.parser", "pandas.io.libparsers", "X"
463463
"pandas.lib", "pandas.libs.lib", "X"
464+
"pandas.tslib", "pandas.libs.tslib", "X"
464465
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
465466
"pandas.msgpack", "pandas.io.msgpack", ""
466-
"pandas.tslib", "pandas.libs.tslib", ""
467467
"pandas.index", "pandas.libs.index", ""
468468
"pandas.algos", "pandas.libs.algos", ""
469469
"pandas.hashtable", "pandas.libs.hashtable", ""

pandas/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
json = _DeprecatedModule(deprmod='pandas.json', deprmodto='pandas.io.json.libjson')
6565
parser = _DeprecatedModule(deprmod='pandas.parser', deprmodto='pandas.io.libparsers')
6666
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto='pandas.libs.lib')
67+
tslib = _DeprecatedModule(deprmod='pandas.tslib', deprmodto='pandas.libs.tslib')
6768

6869
# use the closest tagged version if possible
6970
from ._version import get_versions

pandas/tests/api/test_api.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
from warnings import catch_warnings
34
import numpy as np
45

56
import pandas as pd
@@ -37,7 +38,8 @@ class TestPDApi(Base, tm.TestCase):
3738
'types', 'util', 'options', 'io', 'libs']
3839

3940
# these are already deprecated; awaiting removal
40-
deprecated_modules = ['stats', 'datetools', 'parser', 'json', 'lib']
41+
deprecated_modules = ['stats', 'datetools', 'parser',
42+
'json', 'lib', 'tslib']
4143

4244
# misc
4345
misc = ['IndexSlice', 'NaT']
@@ -244,3 +246,12 @@ def test_deprecation_access_func(self):
244246
with tm.assert_produces_warning(FutureWarning,
245247
check_stacklevel=False):
246248
pd.lib.infer_dtype
249+
250+
251+
class TestTSLib(tm.TestCase):
252+
253+
def test_deprecation_access_func(self):
254+
# some libraries may be imported before we
255+
# test and could show the warning
256+
with catch_warnings(record=True):
257+
pd.tslib.Timestamp

pandas/tslib.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# flake8: noqa
2+
3+
import warnings
4+
warnings.warn("The pandas.tslib module is deprecated and will be "
5+
"removed in a future version. Please import from "
6+
"the pandas.libs.tslib instead", FutureWarning, stacklevel=2)
7+
from pandas.libs.tslib import Timestamp, Timedelta, NaT

pandas/util/depr_module.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def __getattr__(self, name):
7373

7474
return obj
7575

76-
def _import_deprmod(self, mod):
76+
def _import_deprmod(self, mod=None):
77+
if mod is None:
78+
mod = self.deprmod
79+
7780
with warnings.catch_warnings():
7881
warnings.filterwarnings('ignore', category=FutureWarning)
7982
deprmodule = importlib.import_module(mod)

0 commit comments

Comments
 (0)