diff --git a/pandas/core/series.py b/pandas/core/series.py index 98b548f8ab3b5..a53088a4b288e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -77,6 +77,8 @@ from pandas._libs import index as libindex, tslib as libts, lib, iNaT from pandas.core.config import get_option +import pandas.plotting._core as _gfx # noqa + __all__ = ['Series'] _shared_doc_kwargs = dict( @@ -3060,8 +3062,6 @@ def create_from_value(value, index, dtype): # ---------------------------------------------------------------------- # Add plotting methods to Series -import pandas.plotting._core as _gfx # noqa - Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods, _gfx.SeriesPlotMethods) Series.hist = _gfx.hist_series diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 9cceebb5c4cdb..d0f7fcf71dd7e 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -11,7 +11,10 @@ from pandas.util._decorators import cache_readonly from pandas.core.base import PandasObject + +from pandas.core.dtypes.generic import ABCSeries from pandas.core.dtypes.missing import notnull, remove_na_arraylike + from pandas.core.dtypes.common import ( is_list_like, is_integer, @@ -21,7 +24,7 @@ from pandas.core.common import AbstractMethodError, isnull, _try_sort from pandas.core.generic import _shared_docs, _shared_doc_kwargs from pandas.core.index import Index, MultiIndex -from pandas.core.series import Series + from pandas.core.indexes.period import PeriodIndex from pandas.compat import range, lrange, map, zip, string_types import pandas.compat as compat @@ -334,7 +337,11 @@ def result(self): def _compute_plot_data(self): data = self.data - if isinstance(data, Series): + from pandas import Series + if isinstance(data, ABCSeries) != isinstance(data, Series): + raise Exception('WTFError', data) + + if isinstance(data, ABCSeries): label = self.label if label is None and data.name is None: label = 'None' @@ -1494,6 +1501,7 @@ def _args_adjust(self): @classmethod def _plot(cls, ax, y, column_num=None, return_type='axes', **kwds): + from pandas.core.series import remove_na if y.ndim == 2: y = [remove_na_arraylike(v) for v in y] # Boxplot fails with empty arrays, so need to add a NaN @@ -1566,6 +1574,7 @@ def maybe_color_bp(self, bp): def _make_plot(self): if self.subplots: + from pandas import Series self._return_obj = Series() for i, (label, y) in enumerate(self._iter_data()): @@ -1968,6 +1977,7 @@ def maybe_color_bp(bp): setp(bp['medians'], color=colors[2], alpha=1) def plot_group(keys, values, ax): + from pandas.core.series import remove_na keys = [pprint_thing(x) for x in keys] values = [remove_na_arraylike(v) for v in values] bp = ax.boxplot(values, **kwds) @@ -2317,6 +2327,7 @@ def boxplot_frame_groupby(grouped, subplots=True, column=None, fontsize=None, figsize=figsize, layout=layout) axes = _flatten(axes) + from pandas import Series ret = Series() for (key, group), ax in zip(grouped, axes): d = group.boxplot(ax=ax, column=column, fontsize=fontsize, @@ -2388,6 +2399,7 @@ def _grouped_plot_by_column(plotf, data, columns=None, by=None, _axes = _flatten(axes) + from pandas import Series result = Series() ax_values = [] diff --git a/pandas/plotting/_tools.py b/pandas/plotting/_tools.py index 0c2314087525c..1bd7a95e0678d 100644 --- a/pandas/plotting/_tools.py +++ b/pandas/plotting/_tools.py @@ -9,7 +9,6 @@ from pandas.core.dtypes.common import is_list_like from pandas.core.index import Index -from pandas.core.series import Series from pandas.compat import range @@ -44,7 +43,7 @@ def table(ax, data, rowLabels=None, colLabels=None, ------- matplotlib table object """ - from pandas import DataFrame + from pandas import Series, DataFrame if isinstance(data, Series): data = DataFrame(data, columns=[data.name]) elif isinstance(data, DataFrame):