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

Top-level Pandas functions - merge #961

Closed
gatorsmile opened this issue Oct 27, 2019 · 3 comments · Fixed by #969
Closed

Top-level Pandas functions - merge #961

gatorsmile opened this issue Oct 27, 2019 · 3 comments · Fixed by #969
Labels
enhancement New feature or request

Comments

@gatorsmile
Copy link
Collaborator

https://pandas.pydata.org/pandas-docs/stable/reference/general_functions.html

ks.merge(kdf, kdf)

AttributeError: module 'databricks.koalas' has no attribute 'merge'
@itholic
Copy link
Contributor

itholic commented Oct 28, 2019

Thanks for posting issue. i'm going to work on this.

@HyukjinKwon
Copy link
Member

Please go ahead!!

@HyukjinKwon HyukjinKwon added the enhancement New feature or request label Oct 28, 2019
@itholic
Copy link
Contributor

itholic commented Oct 29, 2019

@HyukjinKwon i just finished. could you check related PR when you available?

HyukjinKwon pushed a commit that referenced this issue Oct 30, 2019
Resolves #961 

```python
>>> df1 = ks.DataFrame({'lkey': ['foo', 'bar', 'baz', 'foo'],
...                     'value': [1, 2, 3, 5]},
...                    columns=['lkey', 'value'])
>>> df2 = ks.DataFrame({'rkey': ['foo', 'bar', 'baz', 'foo'],
...                     'value': [5, 6, 7, 8]},
...                    columns=['rkey', 'value'])
>>> df1
  lkey  value
0  foo      1
1  bar      2
2  baz      3
3  foo      5
>>> df2
  rkey  value
0  foo      5
1  bar      6
2  baz      7
3  foo      8

>>> merged = ks.merge(df1, df2, left_on='lkey', right_on='rkey')
>>> merged.sort_values(by=['lkey', 'value_x', 'rkey', 'value_y'])
  lkey  value_x rkey  value_y
0  bar        2  bar        6
5  baz        3  baz        7
1  foo        1  foo        5
2  foo        1  foo        8
3  foo        5  foo        5
4  foo        5  foo        8

>>> left_kdf = ks.DataFrame({'A': [1, 2]})
>>> right_kdf = ks.DataFrame({'B': ['x', 'y']}, index=[1, 2])

>>> ks.merge(left_kdf, right_kdf, left_index=True, right_index=True)
   A  B
1  2  x

>>> ks.merge(left_kdf, right_kdf, left_index=True, right_index=True, how='left')
   A     B
0  1  None
1  2     x

>>> ks.merge(left_kdf, right_kdf, left_index=True, right_index=True, how='right')
     A  B
1  2.0  x
2  NaN  y

>>> ks.merge(left_kdf, right_kdf, left_index=True, right_index=True, how='outer')
     A     B
0  1.0  None
1  2.0     x
2  NaN     y
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants