Add a way to refer to multiple joined frames' columns

Open
#3,421 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start by reproducing the chained join and update expression using dt.Frame, dt.update, join, f, and g. Trace how joined columns are exposed during indexing and define the behavior needed for accessing jf2's D column; done means the example updates C to the expected values without a workaround.

Written by the indexing model from the issue text.

Description

improve

I want to index df on column A with jf and then join with jf2 to update column C with jf2's column D (also naming it C wouldn't help here).

from datatable import dt, f, join, g

df = dt.Frame("""A B C
                 a e 0
                 b e 0
                 b f 0
                 c f 0
                 d f 2""")

jf = dt.Frame("""A
                 b
                 c""")
jf.key = "A"

jf2 = dt.Frame("""B D
                  e 3
                  f 4""")
jf2.key = "B"

So after updating df would be:

df_desired = dt.Frame("""A B C
                         a e 0
                         b e 3
                         b f 4
                         c f 4
                         d f 1""")

Joining works perfectly:

df[g[0] != None, :, join(jf), join(jf2)]
#    | A      B          C      D
#    | str32  str32  int32  int32
# -- + -----  -----  -----  -----
#  0 | b      e          0      3
#  1 | b      f          0      4
#  2 | c      f          0      4
# [3 rows x 4 columns]

But I can't update in the same step because column Dcannot be accessed. I'd like to do something like this:

df[g[0] != None, dt.update(C=g["D"]), join(jf), join(jf2)]
# datatable.exceptions.KeyError: Column D does not exist in the Frame; did you mean A?

The columns of df are in f and the columns of jf are in g, but the columns of jf2 cannot be accessed in the j-statement.

While this is a feature request, I'd also appreciate good ideas for workarounds.

Dominant language
C++
Stars
1.9k
Forks
164
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from h2oai/datatable

All issues in h2oai/datatable

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.