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

Fix column name as a tuple in multi column index #1191

Merged
merged 1 commit into from
Jan 14, 2020

Conversation

HyukjinKwon
Copy link
Member

import pandas as pd
import databricks.koalas as ks
column_index = pd.MultiIndex.from_tuples([('a', 'x'), ('a', 'y'), ('b', 'z')])
pdf = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]], columns=column_index)
pdf.set_index(('a', 'x'), append=True, inplace=True)
ks.from_pandas(pdf)

Before:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../koalas/databricks/koalas/namespace.py", line 70, in from_pandas
    return DataFrame(pobj)
  File "/.../koalas/databricks/koalas/frame.py", line 380, in __init__
    super(DataFrame, self).__init__(_InternalFrame.from_pandas(pdf))
  File "/.../koalas/databricks/koalas/internal.py", line 771, in from_pandas
    column_index_names=column_index_names)
  File "/.../koalas/databricks/koalas/internal.py", line 431, in __init__
    for index_field, index_name in index_map), index_map
AssertionError: [('__index_level_0__', None), (('a', 'x'), ('a', 'x'))]

After:

          a  b
          y  z
  (a, x)
0 1       2  3
1 4       5  6
2 7       8  9

@codecov-io
Copy link

codecov-io commented Jan 13, 2020

Codecov Report

Merging #1191 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1191   +/-   ##
=======================================
  Coverage   95.22%   95.22%           
=======================================
  Files          35       35           
  Lines        7141     7141           
=======================================
  Hits         6800     6800           
  Misses        341      341
Impacted Files Coverage Δ
databricks/koalas/internal.py 95.72% <100%> (ø) ⬆️

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 1e1da27...b915c4a. Read the comment docs.

@softagram-bot
Copy link

Softagram Impact Report for pull/1191 (head commit: b915c4a)

⚠️ Copy paste found

ℹ️ test_indexes.py: Copy paste fragment on line 32 shared with ../test_numpy_compat.py:

    def pdf(self):
        return pd.DataFrame({
            'a': [1, 2, 3, 4, 5, 6, 7, 8, 9],
            'b': [4, 5, 6, 3, 2, 1, 0, 0, 0],
        }, index=[0, 1, 3, 5, 6, 8, 9, 9, 9])...(truncated 101 chars)

Now that you are on the file, it would be easier to pay back some tech. debt.

⭐ Change Overview

Showing the changed files, dependency changes and the impact - click for full size
(Open in Softagram Desktop for full details)

💡 Insights

  • Co-change Alert: You modified test_indexes.py. Often indexes.py (databricks/koalas) is modified at the same time.

📄 Full report

Impact Report explained. Give feedback on this report to [email protected]

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 14, 2020

Thanks! merging.

@ueshin ueshin merged commit 8d0cbe4 into databricks:master Jan 14, 2020
@HyukjinKwon HyukjinKwon deleted the column-tuple branch September 11, 2020 07:52
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