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

DataFrame.pivot without index argument should preserve the original index names. #1316

Merged
merged 1 commit into from
Mar 1, 2020

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Feb 28, 2020

DataFrame.pivot without index argument should preserve the original index names.

>>> import pandas as pd
>>> pdf = pd.DataFrame({"foo": ['one', 'one', 'two', 'two'], "bar": ['A', 'A', 'B', 'C'], "baz": [1, 2, 3, 4]}, columns=['foo', 'bar', 'baz'])
>>> pdf.index.name = 'x'
>>> pdf
   foo bar  baz
x
0  one   A    1
1  one   A    2
2  two   B    3
3  two   C    4
>>> pdf.pivot(columns='bar', values='baz')
bar    A    B    C
x
0    1.0  NaN  NaN
1    2.0  NaN  NaN
2    NaN  3.0  NaN
3    NaN  NaN  4.0

whereas:

>>> ks.from_pandas(pdf).pivot(columns='bar', values='baz').sort_index()
bar    A    B    C
0    1.0  NaN  NaN
1    2.0  NaN  NaN
2    NaN  3.0  NaN
3    NaN  NaN  4.0

@ueshin ueshin requested a review from HyukjinKwon February 28, 2020 23:54
@codecov-io
Copy link

Codecov Report

Merging #1316 into master will decrease coverage by 2.34%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1316      +/-   ##
==========================================
- Coverage   95.23%   92.89%   -2.35%     
==========================================
  Files          34       34              
  Lines        7331     7332       +1     
==========================================
- Hits         6982     6811     -171     
- Misses        349      521     +172
Impacted Files Coverage Δ
databricks/koalas/frame.py 93.55% <100%> (-3.17%) ⬇️
databricks/koalas/usage_logging/__init__.py 24.32% <0%> (-71.18%) ⬇️
databricks/koalas/usage_logging/usage_logger.py 50% <0%> (-50%) ⬇️
databricks/koalas/__init__.py 78.72% <0%> (-14.9%) ⬇️
databricks/conftest.py 88.67% <0%> (-7.55%) ⬇️
databricks/koalas/namespace.py 86.3% <0%> (-1.49%) ⬇️
databricks/koalas/plot.py 93.33% <0%> (-0.96%) ⬇️
databricks/koalas/testing/utils.py 78.26% <0%> (-0.73%) ⬇️
databricks/koalas/groupby.py 91.22% <0%> (-0.22%) ⬇️
... and 1 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 65716a3...8498e8e. Read the comment docs.

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.

Nice, LGTM!

@HyukjinKwon HyukjinKwon merged commit f4eb2ed into databricks:master Mar 1, 2020
@ueshin ueshin deleted the pivot branch March 2, 2020 04:00
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