Skip to content
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

Rank With 'method=first' Broken for Objects #19482

Closed
WillAyd opened this issue Jan 31, 2018 · 3 comments
Closed

Rank With 'method=first' Broken for Objects #19482

WillAyd opened this issue Jan 31, 2018 · 3 comments
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@WillAyd
Copy link
Member

WillAyd commented Jan 31, 2018

Came across this working on #15779

In []: df = pd.DataFrame({'key': ['a'] * 5, 'val': ['bar', 'bar', 'foo', 'bar', 'baz']})
In []: df.groupby('key').rank(method='first')

Out []: 
Empty DataFrame
Columns: []
Index: []

Expected Output

Out[]: 
   val
0  1.0
1  2.0
2  5.0
3  3.0
4  4.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit: d3f7d2a
python: 3.6.3.final.0
python-bits: 64
OS: Darwin
OS-release: 17.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.0.dev0+169.gd3f7d2a66.dirty
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: 0.26.1
numpy: 1.13.3
scipy: 1.0.0
pyarrow: 0.8.0
xarray: 0.10.0
IPython: 6.2.1
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.1.1
openpyxl: 2.5.0b1
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.1.13
pymysql: 0.7.11.None
psycopg2: None
jinja2: 2.10
s3fs: 0.1.2
fastparquet: 0.1.3
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member Author

WillAyd commented Jan 31, 2018

Alternately this could throw a ValueError, which seems to be the intention of the code in algos linked below. That said, I don't see why it would be bad to support this and couldn't find any comment history touching on it. Insights appreciated

raise ValueError('first not supported for non-numeric data')

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations Difficulty Intermediate labels Feb 1, 2018
@jreback jreback added this to the Next Major Release milestone Feb 1, 2018
@jreback
Copy link
Contributor

jreback commented Feb 1, 2018

yeah I think this could be disallowed.

@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Feb 1, 2018
@WillAyd
Copy link
Member Author

WillAyd commented Feb 16, 2018

Fixed as part of #19481

@WillAyd WillAyd closed this as completed Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Error Reporting Incorrect or improved errors from pandas Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

2 participants