Skip to content

Commit 0b244f2

Browse files
committed
Fix pre-commit.ci errors: line length and NumPy API deprecation, proper type checking with isinstance and type ignore
1 parent cc4b0d4 commit 0b244f2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

pandas/core/apply.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,8 @@ def agg_or_apply_list_like(
848848

849849
# Only proceed if we have numeric columns
850850
if not numeric_obj.empty:
851-
# Create kwargs without numeric_only to avoid passing it to Series methods
851+
# Create kwargs without numeric_only to avoid
852+
# passing it to Series methods
852853
kwargs_filtered = {
853854
k: v for k, v in kwargs.items() if k != "numeric_only"
854855
}
@@ -864,7 +865,13 @@ def agg_or_apply_list_like(
864865
from pandas import DataFrame
865866

866867
# Get function names for index
867-
keys = list(self.func) if is_list_like(self.func) else []
868+
if isinstance(self.func, list):
869+
keys = self.func # type: ignore[assignment]
870+
elif isinstance(self.func, dict):
871+
keys = list(self.func.keys())
872+
else:
873+
keys = []
874+
868875
return DataFrame(index=keys)
869876

870877
keys, results = self.compute_list_like(op_name, obj, kwargs)

pandas/tests/apply/test_frame_apply_numeric_only.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,15 @@ def test_agg_list_numeric_only_with_datetime(self):
206206

207207
def test_agg_list_numeric_only_large_dataframe(self):
208208
"""Test with a larger DataFrame for performance verification."""
209-
np.random.seed(42)
209+
rng = np.random.default_rng(42)
210210
df = DataFrame(
211211
{
212-
"A": np.random.randint(1, 100, 1000),
213-
"B": np.random.randn(1000),
212+
"A": rng.integers(1, 100, 1000),
213+
"B": rng.standard_normal(1000),
214214
"C": ["text"] * 1000,
215215
}
216216
)
217+
217218
result = df.agg(["sum", "mean", "std"], numeric_only=True)
218219

219220
# Just verify structure, not exact values due to randomness

0 commit comments

Comments
 (0)