Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi Wei committed Jun 22, 2023
1 parent dc9e2da commit c283efb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ Other enhancements
- Let :meth:`DataFrame.to_feather` accept a non-default :class:`Index` and non-string column names (:issue:`51787`)
- Performance improvement in :func:`read_csv` (:issue:`52632`) with ``engine="c"``
- :meth:`Categorical.from_codes` has gotten a ``validate`` parameter (:issue:`50975`)
- :meth:`DataFrame.hist` and :meth:`Series.hist` use the column names as xlabels and :meth:`DataFrame.hist` supports multiple histograms in a single plot (:issue:`53281`)
- :meth:`DataFrame.stack` gained the ``sort`` keyword to dictate whether the resulting :class:`MultiIndex` levels are sorted (:issue:`15105`)
- :meth:`DataFrame.unstack` gained the ``sort`` keyword to dictate whether the resulting :class:`MultiIndex` levels are sorted (:issue:`15105`)
- :meth:`DataFrame.hist` and :meth: `Series.hist` use the column names as xlabels and :meth:`DataFrame.hist` supports multiple histograms in a single plot (:issue: `53281`)
- :meth:`DataFrameGroupby.agg` and :meth:`DataFrameGroupby.transform` now support grouping by multiple keys when the index is not a :class:`MultiIndex` for ``engine="numba"`` (:issue:`53486`)
- :meth:`Series.explode` now supports pyarrow-backed list types (:issue:`53602`)
- :meth:`Series.str.join` now supports ``ArrowDtype(pa.string())`` (:issue:`53646`)
Expand Down
3 changes: 2 additions & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from matplotlib.axes import Axes
import numpy as np
from numpy._typing import NDArray

from pandas._typing import IndexLabel

Expand Down Expand Up @@ -140,7 +141,7 @@ def hist_frame(
sharey: bool = False,
figsize: tuple[int, int] | None = None,
layout: tuple[int, int] | None = None,
bins: int | Sequence[int] = None,
bins: int | Sequence[int] | NDArray | None = None,
backend: str | None = None,
legend: bool = False,
**kwargs,
Expand Down
15 changes: 8 additions & 7 deletions pandas/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from typing import (
TYPE_CHECKING,
Literal,
Literal, Sequence,
)

import numpy as np
from numpy._typing import NDArray

from pandas.core.dtypes.common import (
is_integer,
Expand Down Expand Up @@ -328,7 +329,7 @@ def _grouped_hist(
column=None,
by=None,
ax=None,
bins: int = 50,
bins: int | Sequence[int] | NDArray | None = None,
figsize: tuple[float, float] | None = None,
layout=None,
sharex: bool = False,
Expand Down Expand Up @@ -387,7 +388,7 @@ def get_column_data(obj, column_name):
raw_column = get_column_data(grouped.obj, column_name)
if bins_copy is None and (numeric_only or is_numeric_dtype(raw_column)):
# precompute reused bins
bins = np.histogram_bin_edges(raw_column, bins="auto")
bins_copy = np.histogram_bin_edges(raw_column, bins="auto")

for key, group in grouped:
column_data = get_column_data(group, column_name)
Expand All @@ -398,15 +399,15 @@ def get_column_data(obj, column_name):
column_data,
alpha=alpha,
label=key,
bins=bins,
bins=bins_copy,
edgecolor=edgecolor,
linewidth=linewidth,
**kwargs,
)
if legend:
ax.legend()

bins = bins_copy
bins_copy = bins

if xrot is None:
xrot = rot
Expand Down Expand Up @@ -446,7 +447,7 @@ def hist_series(
ylabelsize: int | None = None,
yrot=None,
figsize: tuple[float, float] | None = None,
bins: int = 10,
bins: int | Sequence[int] | NDArray | None = None,
legend: bool = False,
**kwds,
):
Expand Down Expand Up @@ -524,7 +525,7 @@ def hist_frame(
sharey: bool = False,
figsize: tuple[float, float] | None = None,
layout=None,
bins: int = 10,
bins: int | Sequence[int] | NDArray | None = None,
legend: bool = False,
alpha: float = 0.5,
edgecolor: str = "black",
Expand Down

0 comments on commit c283efb

Please sign in to comment.