Skip to content

Commit a714649

Browse files
code sample for pandas-dev#46589
1 parent 38f59a1 commit a714649

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

bisect/46589.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# BUG: df.nsmallest get wrong results when row contains NaN #46589
2+
3+
import numpy as np
4+
import pandas as pd
5+
6+
print(pd.__version__)
7+
8+
df = pd.DataFrame(
9+
{
10+
"a": [1, 2, 3, 4, 5, None, 7],
11+
"b": [7, 6, 5, 4, 3, 2, 1],
12+
"c": [1, 1, 2, 2, 3, 3, 3],
13+
},
14+
index=np.random.rand(7),
15+
)
16+
17+
result = df.nsmallest(5, columns=["a", "b"])
18+
print(result)
19+
20+
expected = df.iloc[:5]
21+
pd.testing.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)