-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Avoid circular import between core.series and plotting._xyz #16931
Changes from all commits
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,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) | ||
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. We should make that error available only to developers when they rage-quit 😄 |
||
|
||
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 | ||
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 would be happy to move
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 would allow the import to be at the top 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. That'd be great. 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. About to make a PR that makes this move and nothing else. We'll see if Travis still complains about that. |
||
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 = [] | ||
|
||
|
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.
what is this about?
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.
The first commit for this PR led to a bunch of
TypeError
s on Travis that I can't reproduce locally. My best/only guess as to why is that the checkisinstance(data, ABSeries)
(now at L341) is somehow evaluating differently than the originalisinstance(data, Series)
(previously at L337).So 337-339 is an attempt to check this guess. Regardless of whether the guess is correct, this check will be removed before long.
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.
New hypothesis:
Series._set_subtyp
can sometimes set_subtyp
totime_series
, in which case it will not get recognized asABCSeries
. It tentatively looks like the Travis errors are date-related cases.