diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index b854338c2d1d7..8ebd84226b5e3 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -428,7 +428,7 @@ def cons_row(x): result.name = name return result - def _get_series_list(self, others): + def _get_series_list(self, others) -> list[Series]: """ Auxiliary function for :meth:`str.cat`. Turn potentially mixed input into a list of Series (elements without an index must match the length @@ -479,8 +479,8 @@ def _get_series_list(self, others): for x in others ): los: list[Series] = [] - while others: # iterate through list and append each element - los = los + self._get_series_list(others.pop(0)) + for other in others: + los.extend(self._get_series_list(other)) return los # ... or just strings elif all(not is_list_like(x) for x in others): diff --git a/pandas/plotting/_matplotlib/tools.py b/pandas/plotting/_matplotlib/tools.py index 8ee75e7fe553e..d152735842f45 100644 --- a/pandas/plotting/_matplotlib/tools.py +++ b/pandas/plotting/_matplotlib/tools.py @@ -1,7 +1,11 @@ # being a bit too dynamic from __future__ import annotations -from math import ceil +from math import ( + ceil, + floor, + log2, +) from typing import TYPE_CHECKING import warnings @@ -126,9 +130,7 @@ def _get_layout( try: return layouts[nplots] except KeyError: - k = 1 - while k**2 < nplots: - k += 1 + k = floor(log2(nplots)) + 1 if (k - 1) * k >= nplots: return k, (k - 1)