Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Dec 16, 2019

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.set_names.html#pandas.Index.set_names

>>> idx = ks.Index([1, 2, 3, 4])
>>> idx
Int64Index([1, 2, 3, 4], dtype='int64')

>>> idx.set_names('quarter')
Int64Index([1, 2, 3, 4], dtype='int64', name='quarter')

For MultiIndex

>>> idx = ks.MultiIndex.from_tuples([('a', 'x'), ('b', 'y')])
>>> idx
MultiIndex([('a', 'x'),
            ('b', 'y')],
           )

>>> idx.set_names(['kind', 'year'], inplace=True)
>>> idx
MultiIndex([('a', 'x'),
            ('b', 'y')],
           names=['kind', 'year'])

>>> idx.set_names('species', level=0)
MultiIndex([('a', 'x'),
            ('b', 'y')],
           names=['species', 'year'])

@itholic
Copy link
Contributor Author

itholic commented Dec 16, 2019

this PR is including fix of rename(),

make inplace=True to return nothing but just change its name like pandas.

existing

>>> idx = ks.Index([1, 2, 3, 4])
>>> idx
Int64Index([1, 2, 3, 4], dtype='int64')

>>> idx.rename('quarter', inplace=True)
Int64Index([1, 2, 3, 4], dtype='int64', name='quarter')

fixed (same with pandas)

>>> idx = ks.Index([1, 2, 3, 4])
>>> idx
Int64Index([1, 2, 3, 4], dtype='int64')

>>> idx.rename('quarter', inplace=True)  # nothing to be returned, just change
>>> idx
Int64Index([1, 2, 3, 4], dtype='int64', name='quarter')

@codecov-io
Copy link

codecov-io commented Dec 16, 2019

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1134      +/-   ##
==========================================
+ Coverage   95.22%   95.23%   +<.01%     
==========================================
  Files          35       35              
  Lines        7059     7065       +6     
==========================================
+ Hits         6722     6728       +6     
  Misses        337      337
Impacted Files Coverage Δ
databricks/koalas/missing/indexes.py 100% <ø> (ø) ⬆️
databricks/koalas/indexes.py 96.73% <100%> (+0.08%) ⬆️

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 91ec06a...33d997c. Read the comment docs.

@HyukjinKwon
Copy link
Member

@itholic, can you rebase? seems good.

@itholic
Copy link
Contributor Author

itholic commented Dec 30, 2019

@HyukjinKwon okay i just rebased it. thanks !

@HyukjinKwon HyukjinKwon merged commit 119ae31 into databricks:master Jan 3, 2020
@itholic itholic deleted the i_mi_set_names branch February 6, 2020 15:10
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