zhengruifeng commented on PR #37369:
URL: https://github.com/apache/spark/pull/37369#issuecomment-1204668069

   maybe we still need type checking in this PR:
   
   ```python
   In [1]: import pandas as pd
   
   In [2]: import pyspark.pandas as ps
   
   In [3]: df = pd.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}, 
columns=['A', 'B'])
   
   In [4]: df.groupby(['A'])['B'].nsmallest(5.5)
   ...
   TypeError: cannot do positional indexing on Int64Index with these indexers 
[5.5] of type float
   
   In [5]: df = ps.DataFrame({'A': [1, 2, 3, 4], 'B': [3, 4, 5, 6]}, 
columns=['A', 'B'])
   
   In [6]: df.groupby(['A'])['B'].nsmallest(5.5)
   
   A
   1  0    3
   2  1    4
   3  2    5
   4  3    6
   Name: B, dtype: int64
   
   In [7]: df.groupby(['A'])['B'].nsmallest("5.5")
   Out[7]:
   A
   1  0    3
   2  1    4
   3  2    5
   4  3    6
   Name: B, dtype: int64
   ```
   
   `ps` runs successfully with `5.5` and `"5.5"`, while`pd` throws a `TypeError`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to