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

Throw a better exception in DataFrame.sort_values when multi-index column is used #1238

Merged
merged 2 commits into from
Jan 30, 2020

Conversation

HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 29, 2020

Previously, it threw the exception as below:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../koalas/databricks/koalas/frame.py", line 5398, in sort_values
    by = [self[colname]._scol for colname in by]
  File "/.../koalas/databricks/koalas/frame.py", line 5398, in <listcomp>
    by = [self[colname]._scol for colname in by]
  File "/.../koalas/databricks/koalas/frame.py", line 8334, in __getattr__
    "'%s' object has no attribute '%s'" % (self.__class__.__name__, key))
AttributeError: 'DataFrame' object has no attribute '_scol'

Can be tested as below:

import pandas as pd
import databricks.koalas as ks

mi = pd.MultiIndex.from_tuples([('a', 'b')])
kdf = ks.range(10)
kdf.columns = mi
kdf.sort_values("a")

@HyukjinKwon HyukjinKwon force-pushed the error-message-sort-values branch 2 times, most recently from 7bd5ee3 to fc8fd5f Compare January 29, 2020 09:24
@HyukjinKwon HyukjinKwon force-pushed the error-message-sort-values branch from fc8fd5f to 43a2261 Compare January 29, 2020 09:26
@HyukjinKwon HyukjinKwon requested a review from ueshin January 29, 2020 09:28
@codecov-io
Copy link

codecov-io commented Jan 29, 2020

Codecov Report

Merging #1238 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1238      +/-   ##
==========================================
- Coverage   95.18%   95.12%   -0.06%     
==========================================
  Files          35       35              
  Lines        7265     7226      -39     
==========================================
- Hits         6915     6874      -41     
- Misses        350      352       +2
Impacted Files Coverage Δ
databricks/koalas/frame.py 96.85% <ø> (-0.12%) ⬇️
databricks/conftest.py 96.22% <0%> (-1.78%) ⬇️
databricks/koalas/generic.py 96.1% <0%> (-0.21%) ⬇️
databricks/koalas/config.py 98.98% <0%> (ø) ⬆️
databricks/koalas/series.py 96.47% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d8fbb1...3f01a51. Read the comment docs.

Copy link
Collaborator

@ueshin ueshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM.

@HyukjinKwon HyukjinKwon merged commit 55ee4f8 into databricks:master Jan 30, 2020
@HyukjinKwon HyukjinKwon deleted the error-message-sort-values branch September 11, 2020 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants