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

Adjust data column names before attaching default index. #1947

Merged
merged 5 commits into from
Dec 8, 2020

Conversation

ueshin
Copy link
Collaborator

@ueshin ueshin commented Dec 3, 2020

Adjust data column names before attaching default index; otherwise reset_index() could fail when the DataFrame or Series is converted from Index.

>>> kdf = ks.Index([10, 20, 30]).to_frame()
>>> kdf
     0
10  10
20  20
30  30
>>> kdf.reset_index()
Traceback (most recent call last):
...
AssertionError: Index columns should not appear in columns of the Spark DataFrame. Avoid index column names [re.compile('__index_level_[0-9]+__')].

or

>>> kser = ks.Index([10, 20, 30]).to_series()
>>> kser
10    10
20    20
30    30
dtype: int64
>>> kser.reset_index(drop=True)
Traceback (most recent call last):
...
AssertionError: Index columns should not appear in columns of the Spark DataFrame. Avoid index column names [re.compile('__index_level_[0-9]+__')].

@codecov-io
Copy link

codecov-io commented Dec 3, 2020

Codecov Report

Merging #1947 (c761493) into master (138c7b8) will decrease coverage by 2.54%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1947      +/-   ##
==========================================
- Coverage   94.64%   92.10%   -2.55%     
==========================================
  Files          49       49              
  Lines       10818    10711     -107     
==========================================
- Hits        10239     9865     -374     
- Misses        579      846     +267     
Impacted Files Coverage Δ
databricks/koalas/frame.py 96.09% <100.00%> (-0.67%) ⬇️
databricks/koalas/series.py 96.91% <100.00%> (-0.13%) ⬇️
...bricks/koalas/tests/plot/test_frame_plot_plotly.py 26.58% <0.00%> (-73.42%) ⬇️
databricks/koalas/usage_logging/__init__.py 25.66% <0.00%> (-66.65%) ⬇️
...ricks/koalas/tests/plot/test_series_plot_plotly.py 37.50% <0.00%> (-58.80%) ⬇️
databricks/koalas/usage_logging/usage_logger.py 47.82% <0.00%> (-52.18%) ⬇️
databricks/koalas/__init__.py 79.68% <0.00%> (-10.94%) ⬇️
databricks/koalas/accessors.py 86.43% <0.00%> (-7.04%) ⬇️
databricks/conftest.py 93.22% <0.00%> (-6.78%) ⬇️
databricks/koalas/generic.py 88.18% <0.00%> (-4.74%) ⬇️
... and 20 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 138c7b8...c761493. Read the comment docs.

@ueshin ueshin marked this pull request as draft December 3, 2020 21:56
@ueshin ueshin changed the title Fix reset_index on the object converted from Index. Adjust data column names before attaching default index. Dec 4, 2020
@ueshin ueshin marked this pull request as ready for review December 4, 2020 01:54
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.

Thanks Takuya. I think this looks fine to me.

@ueshin
Copy link
Collaborator Author

ueshin commented Dec 8, 2020

Thanks! merging.

@ueshin ueshin merged commit 01ada38 into databricks:master Dec 8, 2020
@ueshin ueshin deleted the fix_reset_index branch December 8, 2020 01:41
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