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

Fix Dataframe.melt function & Add doctest case for melt function #987

Merged
merged 15 commits into from
Nov 8, 2019

Conversation

fwani
Copy link
Contributor

@fwani fwani commented Oct 31, 2019

There is no test that tested with str, tuple type of value_vars parameter at Dataframe.melt function.
I update doctest case.
Screen Shot 2019-10-31 at 5 36 37 PM

And, I thought, There is a bug like the image below.
Screen Shot 2019-10-31 at 5 46 57 PM

I changed some codes.

@itholic
Copy link
Contributor

itholic commented Oct 31, 2019

nice finding

@codecov-io
Copy link

codecov-io commented Oct 31, 2019

Codecov Report

Merging #987 into master will increase coverage by 0.13%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #987      +/-   ##
==========================================
+ Coverage   94.83%   94.96%   +0.13%     
==========================================
  Files          34       34              
  Lines        6640     6713      +73     
==========================================
+ Hits         6297     6375      +78     
+ Misses        343      338       -5
Impacted Files Coverage Δ
databricks/koalas/frame.py 96.49% <100%> (+0.23%) ⬆️
databricks/koalas/window.py 92.96% <0%> (-1.29%) ⬇️
databricks/koalas/groupby.py 91.39% <0%> (ø) ⬆️
databricks/koalas/missing/frame.py 100% <0%> (ø) ⬆️
databricks/koalas/generic.py 95.73% <0%> (ø) ⬆️
databricks/koalas/indexing.py 94.38% <0%> (ø) ⬆️
databricks/koalas/utils.py 98.12% <0%> (ø) ⬆️
databricks/koalas/missing/series.py 100% <0%> (ø) ⬆️
databricks/koalas/namespace.py 87.3% <0%> (+0.03%) ⬆️
databricks/koalas/internal.py 96.42% <0%> (+0.04%) ⬆️
... and 4 more

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 e596a58...551b3ea. 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.

@fwani Good catch!
But I'm afraid the fix is not a good direction. Please see the comment below.
Thanks!

databricks/koalas/frame.py Show resolved Hide resolved
@fwani
Copy link
Contributor Author

fwani commented Nov 4, 2019

@ueshin
I don't know if I understand your opinion well,
but I added codes to catch some exceptions in melt function.

databricks/koalas/frame.py Outdated Show resolved Hide resolved
databricks/koalas/frame.py Outdated Show resolved Hide resolved
databricks/koalas/frame.py Outdated Show resolved Hide resolved
databricks/koalas/frame.py Outdated Show resolved Hide resolved
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.

Comment on lines 6819 to 6820
raise KeyError("None of [{}] are in the [columns]"
.format(pd.MultiIndex.from_tuples(non_existence_col)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error message is strange?

KeyError: "None of [MultiIndex(levels=[['X'], ['Y']],\n           codes=[[0], [0]])] are in the [columns]"

How about:

-                    raise KeyError("None of [{}] are in the [columns]"
-                                   .format(pd.MultiIndex.from_tuples(non_existence_col)))
+                    raise KeyError("None of {} are in the {}"
+                                   .format(non_existence_col, column_index))

then

KeyError: "None of [('X', 'Y')] are in the [('X', 'A'), ('X', 'B'), ('Y', 'C')]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you.
I'll change error message the case of id_vars, value_vars.

Comment on lines 6847 to 6848
raise KeyError("None of [{}] are in the [columns]"
.format(pd.MultiIndex.from_tuples(non_existence_col)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto.

@softagram-bot
Copy link

Softagram Impact Report for pull/987 (head commit: 551b3ea)

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

📄 Full report

Impact Report explained. Give feedback on this report to [email protected]

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.

LGTM.

@ueshin
Copy link
Collaborator

ueshin commented Nov 8, 2019

Thanks! merging.

@ueshin ueshin merged commit c4deb88 into databricks:master Nov 8, 2019
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.

5 participants