-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.nlargest result error #16314
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
Comments
what exactly is the problem? show the full |
This is exactly what should be reported.
|
Yeah, so it appears that it doesn't handle dtypes that are "objects" since it wasn't built to handle sorting strings.
|
@jreback @lesley2958
output:
|
What might be a reason for confusion here (depending on the version @flystarhe is using) is that there is a difference between 0.19.2 and 0.20
That said, the output of 0.19.2 also seems wrong (even if object columns would be allowed). -> but that seems to be fixed: #15297 |
Given that the following methods that rely on order work for object dtype:
you could also say nlargest should work for object dtype. |
@jorisvandenbossche But it doesn't solve the problem. Because nlargest has different efficiencies and computational idea |
This already raised for Series in 0.19.2, but not for DataFrame. This was unified to disallow object columns generally and take on the Series behavior (and of course fix the actual duplicated issues)
|
@flystarhe your question is not clear These might be what you want
|
It was not meant to solve your problem (which you should try to explain better). I was just giving a possible reason to allow nlargest on object columns. But since we also raise for series, I don't think we are going to change this. |
Closing as the current behavior is intended and correct. |
better still since it does deals string format. |
Code Sample, a copy-pastable example if possible
Problem description
DataFrame的nlargest在遇到rank相同的情况时,结果错误。如下,第二行和第四行反复出现了。
Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: