Skip to content

CLN: Unnecessary while loops #60841

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
10 changes: 6 additions & 4 deletions pandas/plotting/_matplotlib/tools.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down
Loading