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.keys #935

Merged
merged 3 commits into from
Oct 21, 2019
Merged

Implement Series.keys #935

merged 3 commits into from
Oct 21, 2019

Conversation

itholic
Copy link
Contributor

@itholic itholic commented Oct 17, 2019

An alias for index.

>>> midx = pd.MultiIndex([['lama', 'cow', 'falcon'],
...                       ['speed', 'weight', 'length']],
...                      [[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                       [0, 1, 2, 0, 1, 2, 0, 1, 2]])
>>> kser = ks.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3], index=midx)
>>> pser = kser.to_pandas()

>>> pser.keys()
MultiIndex([(  'lama',  'speed'),
            (  'lama', 'weight'),
            (  'lama', 'length'),
            (   'cow',  'speed'),
            (   'cow', 'weight'),
            (   'cow', 'length'),
            ('falcon',  'speed'),
            ('falcon', 'weight'),
            ('falcon', 'length')],
           )

>>> kser.keys()
MultiIndex([(  'lama',  'speed'),
            (  'lama', 'weight'),
            (  'lama', 'length'),
            (   'cow',  'speed'),
            (   'cow', 'weight'),
            (   'cow', 'length'),
            ('falcon',  'speed'),
            ('falcon', 'weight'),
            ('falcon', 'length')],
           )

@codecov-io
Copy link

codecov-io commented Oct 17, 2019

Codecov Report

Merging #935 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #935      +/-   ##
==========================================
+ Coverage   94.46%   94.46%   +<.01%     
==========================================
  Files          34       34              
  Lines        6382     6383       +1     
==========================================
+ Hits         6029     6030       +1     
  Misses        353      353
Impacted Files Coverage Δ
databricks/koalas/missing/series.py 100% <ø> (ø) ⬆️
databricks/koalas/series.py 95.6% <100%> (+0.01%) ⬆️

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 465861c...6426262. 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.

databricks/koalas/series.py Show resolved Hide resolved
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

@itholic
Copy link
Contributor Author

itholic commented Oct 19, 2019

@ueshin @HyukjinKwon i think they have different behavior about showing index as print out,

in python3.7

Expected:
    MultiIndex([(  'lama',  'speed'),
                (  'lama', 'weight'),
                (  'lama', 'length'),
                (   'cow',  'speed'),
                (   'cow', 'weight'),
                (   'cow', 'length'),
                ('falcon',  'speed'),
                ('falcon', 'weight'),
                ('falcon', 'length')],
               )

but python3.5 & python3.6

Got:
    MultiIndex(levels=[['cow', 'falcon', 'lama'], ['length', 'speed', 'weight']],
               labels=[[2, 2, 2, 0, 0, 0, 1, 1, 1], [1, 2, 0, 1, 2, 0, 1, 2, 0]])

so the doctest raises error,

any idea how to fix this?

i think maybe we can just skip doctest or remove examples from doctest

@ueshin
Copy link
Collaborator

ueshin commented Oct 19, 2019

@itholic Let's keep the 3.7 result and skip the doctest.

@itholic
Copy link
Contributor Author

itholic commented Oct 19, 2019

@ueshin i think it's better too. thanks for your comment!!

@softagram-bot
Copy link

Softagram Impact Report for pull/935 (head commit: 6426262)

⭐ 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]

@HyukjinKwon HyukjinKwon merged commit e947b54 into databricks:master Oct 21, 2019
@itholic itholic deleted the s_keys branch October 23, 2019 04:26
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