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

Implement Series.plot.box with plotly #2007

Merged
merged 1 commit into from
Jan 15, 2021

Conversation

HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Jan 14, 2021

This PR implements Series.plot.box with plotly. Note that DataFrame.plot.box is not already supported in Koalas yet.
This can be tested via the link: https://mybinder.org/v2/gh/HyukjinKwon/koalas/plot-box-ser?filepath=docs%2Fsource%2Fgetting_started%2F10min.ipynb

Note that you should manually install plotly to test with mybinder above:

%%bash
pip install plotly

Example:

# Koalas
from databricks import koalas as ks
ks.options.plotting.backend = "plotly"
kdf = ks.DataFrame({"a": [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 50],}, index=[0, 1, 3, 5, 6, 8, 9, 9, 9, 10, 10])
kdf.a.plot.box()

# pandas
import pandas as pd
pd.options.plotting.backend = "plotly"
pdf = pd.DataFrame({"a": [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 50],}, index=[0, 1, 3, 5, 6, 8, 9, 9, 9, 10, 10])
pdf.a.plot.box()

Screen Shot 2021-01-14 at 6 56 19 PM
Screen Shot 2021-01-14 at 6 56 24 PM

For the same reason as #1999, the output is slightly different from pandas'.
I referred to "Box Plot With Precomputed Quartiles" in https://plotly.com/python/box-plots/

@HyukjinKwon HyukjinKwon requested a review from ueshin January 14, 2021 09:40
@HyukjinKwon
Copy link
Member Author

This PR is dependent on #2006

@codecov-io
Copy link

codecov-io commented Jan 14, 2021

Codecov Report

Merging #2007 (4d82385) into master (d0f4ad2) will increase coverage by 0.00%.
The diff coverage is 96.29%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2007   +/-   ##
=======================================
  Coverage   94.57%   94.58%           
=======================================
  Files          50       50           
  Lines       11142    11192   +50     
=======================================
+ Hits        10538    10586   +48     
- Misses        604      606    +2     
Impacted Files Coverage Δ
databricks/koalas/plot/plotly.py 96.05% <94.44%> (-1.68%) ⬇️
...ricks/koalas/tests/plot/test_series_plot_plotly.py 98.05% <100.00%> (+0.41%) ⬆️

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 d0f4ad2...4d82385. Read the comment docs.

@HyukjinKwon HyukjinKwon force-pushed the plot-box-ser branch 3 times, most recently from 6f19c3c to 422a075 Compare January 15, 2021 01:05
@HyukjinKwon
Copy link
Member Author

I tired hard but couldn't figure out how to remove this 0 .. 😢
Screen Shot 2021-01-15 at 10 05 49 AM (in the PR description)

@HyukjinKwon
Copy link
Member Author

this is ready for a review.

@HyukjinKwon
Copy link
Member Author

HyukjinKwon commented Jan 15, 2021

BTW, Koalas boxplot will additionally also show the mean value (dot dash line) unlike pandas':
Screen Shot 2021-01-15 at 10 07 16 AM

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 Jan 15, 2021

Thanks! merging.

@ueshin ueshin merged commit 26e5a2d into databricks:master Jan 15, 2021
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.

4 participants