Skip to content

Commit 6ecc984

Browse files
author
Roger Thomas
committed
Refactor
1 parent dd771e6 commit 6ecc984

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pandas/tests/frame/test_analytics.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,14 +1985,11 @@ def test_n_error(self, df_strings):
19851985
columns_with_errors = {'category_string', 'string'}
19861986
columns_without_errors = list(set(df) - columns_with_errors)
19871987
for column in columns_with_errors:
1988-
with pytest.raises(TypeError):
1989-
df.nsmallest(2, column)
1990-
with pytest.raises(TypeError):
1991-
df.nsmallest(2, ['group', column])
1992-
with pytest.raises(TypeError):
1993-
df.nlargest(2, column)
1994-
with pytest.raises(TypeError):
1995-
df.nlargest(2, ['group', column])
1988+
for columns in (column, ['group', column]):
1989+
with pytest.raises(TypeError):
1990+
df.nsmallest(2, columns)
1991+
with pytest.raises(TypeError):
1992+
df.nlargest(2, columns)
19961993
df.nsmallest(2, columns_without_errors)
19971994
df.nsmallest(2, ['int', 'string']) # int column is unique => OK
19981995

0 commit comments

Comments
 (0)