Description
Example
df = pd.concat({
'a': pd.DataFrame({
'col1': [1, 2],
'col2': [3, 4]
}),
'b': pd.DataFrame({
'col3': [5, 6],
'col4': [7, 8]
}),
}, axis=1)
a | b | |||
---|---|---|---|---|
col1 | col2 | col3 | col4 | |
0 | 1 | 3 | 5 | 7 |
1 | 2 | 4 | 6 | 8 |
df.groupby(level=0, axis=1).rank(axis=1, ascending=False, method='first')
ValueError: Shape of passed values is (4, 2), indices imply (2, 2)
Problem description
Should return a data frame with values indicating the rank for each row and within each upper level column. This works in 0.22.0 but in 0.24.2 it fails with the ValueError. It fails in both py 2.7 and py 3.68.
Expected Output
a | b | |||
---|---|---|---|---|
col1 | col2 | col3 | col4 | |
0 | 2.0 | 1.0 | 2.0 | 1.0 |
1 | 2.0 | 1.0 | 2.0 | 1.0 |
Output of pd.show_versions()
[paste the output of pd.show_versions()
here below this line]
INSTALLED VERSIONS
commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 79 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.22.0
pytest: 3.0.5
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.4.2
numexpr: 2.6.1
feather: None
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: 1.0.1
sqlalchemy: 1.1.5
pymysql: None
psycopg2: 2.7.3.2 (dt dec pq3 ext lo64)
jinja2: 2.9.4
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None