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

Unexpected join_left #930

Closed
flexatone opened this issue May 6, 2024 · 1 comment · Fixed by #931
Closed

Unexpected join_left #930

flexatone opened this issue May 6, 2024 · 1 comment · Fixed by #931

Comments

@flexatone
Copy link
Contributor

Thanks, @michaeljpeters , for isolating this.

>>> co = sf.Frame.from_dict_records(
...     [
...         {"gvkey": "123456", "company_name": "A0"},
...         {"gvkey": "567890", "company_name": "A1"},
...         {"gvkey": "234567", "company_name": "B"},
...         {"gvkey": "345678", "company_name": "C"},
...         {"gvkey": "456789", "company_name": "D"},
...     ]
... )
>>> gvk_to_cik = sf.Frame.from_dict_records(
...     [
...         {"gvkey-b": "123456", "cik": 1111},
...         {"gvkey-b": "567890", "cik": 1111},
...         {"gvkey-b": "345678", "cik": 3333},
...         {"gvkey-b": "456789", "cik": 4444},
...     ]
... )
>>> co_w_cik = co.join_left(
...     gvk_to_cik,
...     left_columns="gvkey",
...     right_columns="gvkey-b",
...     fill_value="-1",  # intentional string
... )

>>> co_w_cik
<Frame>
<Index> gvkey  company_name gvkey-b cik     <<U12>
<Index>
0       123456 A0           123456  1111
1       567890 A1           567890  1111
2       234567 B            345678  3333 # not expected
3       345678 C            345678  3333
4       456789 D            456789  4444
<int64> <<U6>  <<U2>        <<U6>   <int64>
@flexatone flexatone linked a pull request May 7, 2024 that will close this issue
@flexatone
Copy link
Contributor Author

Thanks again for this issue. This has been corrected and bundled with numerous performance enhancements.

>>> co = sf.Frame.from_dict_records(
... ...     [
... ...         {"gvkey": "123456", "company_name": "A0"},
... ...         {"gvkey": "567890", "company_name": "A1"},
... ...         {"gvkey": "234567", "company_name": "B"},
... ...         {"gvkey": "345678", "company_name": "C"},
... ...         {"gvkey": "456789", "company_name": "D"},
... ...     ]
... ... )
>>> gvk_to_cik = sf.Frame.from_dict_records(
... ...     [
... ...         {"gvkey-b": "123456", "cik": 1111},
... ...         {"gvkey-b": "567890", "cik": 1111},
... ...         {"gvkey-b": "345678", "cik": 3333},
... ...         {"gvkey-b": "456789", "cik": 4444},
... ...     ]
... ... )
>>> co.join_left(
... ...     gvk_to_cik,
... ...     left_columns="gvkey",
... ...     right_columns="gvkey-b",
... ...     fill_value="-1",  # intentional string
... ... )
<Frame>
<Index> gvkey  company_name gvkey-b cik      <<U12>
<Index>
0       123456 A0           123456  1111
1       567890 A1           567890  1111
2       234567 B            -1      -1
3       345678 C            345678  3333
4       456789 D            456789  4444
<int64> <<U6>  <<U2>        <<U6>   <object>

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 a pull request may close this issue.

1 participant