-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: move plotting funcs to pd.plotting #13579
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 all commits
fb94cc6
c545273
2c4bbb6
1c1efe1
fe8b918
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ Highlights include: | |
|
||
- Building pandas for development now requires ``cython >= 0.23`` (:issue:`14831`) | ||
- The ``.ix`` indexer has been deprecated, see :ref:`here <whatsnew_0200.api_breaking.deprecate_ix>` | ||
- The ``pandas.tools.plotting`` module has been deprecated, moved to ``pandas.plotting``. See :ref:`here <whatsnew_0200.api_breaking.plotting>` (:issue:`12548`) | ||
|
||
Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations <whatsnew_0200.deprecations>` before updating. | ||
|
||
|
@@ -194,6 +195,31 @@ Using ``.iloc``. Here we will get the location of the 'A' column, then use *posi | |
df.iloc[[0, 2], df.columns.get_loc('A')] | ||
|
||
|
||
.. _whatsnew_0200.api_breaking.deprecate_plotting | ||
|
||
Deprecate .plotting | ||
^^^^^^^^^^^^^^^^^^^ | ||
|
||
``pandas.tools.plotting`` module has been deprecated, moving directory under the | ||
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. The |
||
top namespace ``pandas.plotting``. All the public plotting functions should be available | ||
from ``pandas.plotting``. | ||
|
||
Also, ``scatter_matrix`` function imported directly under ``pandas`` namespace is also 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.
|
||
Users shoud use ``pandas.plotting.scatter_matrix`` instead. | ||
|
||
Previous script: | ||
|
||
.. code-block:: python | ||
|
||
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. add |
||
pd.tools.plotting.scatter_matrix(df) | ||
pd.scatter_matrix(df) | ||
|
||
Should be changed to: | ||
|
||
.. code-block:: python | ||
|
||
pd.plotting.scatter_matrix(df) | ||
|
||
.. _whatsnew_0200.api_breaking.index_map | ||
|
||
Map on Index types now return other Index types | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,15 @@ | |
from pandas.tools.merge import (merge, concat, ordered_merge, | ||
merge_ordered, merge_asof) | ||
from pandas.tools.pivot import pivot_table, crosstab | ||
from pandas.tools.plotting import scatter_matrix, plot_params | ||
|
||
# deprecate tools.plotting, and scatter_matrix on the top namespace | ||
import pandas.tools.plotting | ||
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. you can actually deprecate |
||
from pandas.plotting import plot_params | ||
# do not import deprecate to top namespace | ||
scatter_matrix = pandas.util.decorators.deprecate( | ||
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. any reason NOT to remove 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. +1 on moving plot_params as well |
||
'pandas.scatter_matrix', pandas.plotting.scatter_matrix, | ||
'pandas.plotting.scatter_matrix') | ||
|
||
from pandas.tools.tile import cut, qcut | ||
from pandas.tools.util import to_numeric | ||
from pandas.core.reshape import melt | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from pandas.plotting.api import * # noqa |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Plotting api | ||
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. I know this is a bit the style in other pandas modules as well, but can't we just put this in 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. I think this is cleaner here actually. And it is only imported explicity (unlike 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. What do you mean with implicitly imported? The difference with the other modules where we use this pattern, is that, eg in 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. what I mean is, unless you explicity reference these imports, like thoughI guess for back-compat this is needed. IOW, the imports for things like |
||
""" | ||
|
||
# flake8: noqa | ||
|
||
try: # mpl optional | ||
from pandas.plotting import converter | ||
converter.register() # needs to override so set_xlim works with str/number | ||
except ImportError: | ||
pass | ||
|
||
from pandas.plotting.misc import (scatter_matrix, radviz, | ||
andrews_curves, bootstrap_plot, | ||
parallel_coordinates, lag_plot, | ||
autocorrelation_plot) | ||
from pandas.plotting.core import (boxplot, scatter_plot, grouped_hist, | ||
hist_frame, hist_series) | ||
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. I think I mentioned this before, but is there use in exposing 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. The documentation argument is actually also true for |
||
from pandas.plotting.style import plot_params | ||
from pandas.plotting.tools import table |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# being a bit too dynamic | ||
# pylint: disable=E1101 | ||
from __future__ import division | ||
|
||
from distutils.version import LooseVersion | ||
|
||
|
||
def _mpl_le_1_2_1(): | ||
try: | ||
import matplotlib as mpl | ||
return (str(mpl.__version__) <= LooseVersion('1.2.1') and | ||
str(mpl.__version__)[0] != '0') | ||
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. I had to add these checks for |
||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_1_3_1(): | ||
try: | ||
import matplotlib | ||
# The or v[0] == '0' is because their versioneer is | ||
# messed up on dev | ||
return (matplotlib.__version__ >= LooseVersion('1.3.1') or | ||
matplotlib.__version__[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_1_4_0(): | ||
try: | ||
import matplotlib | ||
return (matplotlib.__version__ >= LooseVersion('1.4') or | ||
matplotlib.__version__[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_1_5_0(): | ||
try: | ||
import matplotlib | ||
return (matplotlib.__version__ >= LooseVersion('1.5') or | ||
matplotlib.__version__[0] == '0') | ||
except ImportError: | ||
return False | ||
|
||
|
||
def _mpl_ge_2_0_0(): | ||
try: | ||
import matplotlib | ||
return matplotlib.__version__ >= LooseVersion('2.0') | ||
except ImportError: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from pandas.tools.plotting import scatter_matrix
from matplotlib import cm
feature_names = ['mass', 'width', 'height', 'color_score']
X = fruits[feature_names]
y = fruits['fruit_label']
cmap = cm.get_cmap('gnuplot')
scatter = pd.scatter_matrix(X, c = y, marker = 'o', s=40, hist_kwds={'bins':15}, figsize=(9,9), cmap = cmap)
plt.suptitle('Scatter-matrix for each input variable')
plt.savefig('fruits_scatter_matrix')