Skip to content

Commit 21c9c99

Browse files
committed
Add deprecation wrapper
1 parent d1bcecc commit 21c9c99

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

pandas/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
from pandas.tools.merge import (merge, concat, ordered_merge,
4747
merge_ordered, merge_asof)
4848
from pandas.tools.pivot import pivot_table, crosstab
49-
from pandas.tools.plotting import scatter_matrix, plot_params
49+
50+
# deprecated
51+
import pandas.tools.plotting
52+
from pandas.plotting import scatter_matrix, plot_params
5053
from pandas.tools.tile import cut, qcut
5154
from pandas.tools.util import to_numeric
5255
from pandas.core.reshape import melt

pandas/tools/plotting.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
# flake8: noqa
1+
import sys
2+
import warnings
23

3-
from pandas.plotting.api import *
4+
import pandas.plotting.api as api
5+
6+
# back-compat of public API
7+
# deprecate these functions
8+
m = sys.modules['pandas.tools.plotting']
9+
for t in [t for t in dir(api) if not t.startswith('_')]:
10+
11+
def outer(t=t):
12+
13+
def wrapper(*args, **kwargs):
14+
warnings.warn("pandas.tools.plotting{t} is deprecated. "
15+
"import from the "
16+
"pandas.plotting.{t} instead".format(t=t),
17+
UserWarning, stacklevel=3)
18+
return getattr(api, t)(*args, **kwargs)
19+
return wrapper
20+
21+
setattr(m, t, outer(t))

0 commit comments

Comments
 (0)