14.12.9 Joining PGX Frames
You can join two frames whose rows are correlated through one of the columns using the join
functionality. This allows us to combine frames by checking for equality between rows for a specific column.
The following example shows joining two PgxFrames exampleFrame
and moreInfoFrame
on the name
column by calling the join
method.
Joining PgxFrames Using
JShell
opg4j> exampleFrame.join(moreInfoFrame, "name", "leftFrame", "rightFrame").print();
Joining PgxFrames Using Java
exampleFrame.join(moreInfoFrame, "name", "leftFrame", "rightFrame").print();
The result may appear as shown:
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| leftFrame_name | leftFrame_age | leftFrame_salary | leftFrame_married | leftFrame_tax_rate | leftFrame_random | leftFrame_date_of_birth | rightFrame_name | rightFrame_title | rightFrame_reports |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| John | 27 | 4133300.0 | true | 11.0 | 123456782 | 1985-10-18 | John | Software Engineering Manager | 5 |
| Albert | 23 | 5813000.5 | false | 12.0 | 124343142 | 2000-01-14 | Albert | Sales Manager | 10 |
| Emily | 24 | 9380080.5 | false | 13.0 | 128973221 | 1910-07-30 | Emily | Operations Manager | 20 |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
The joined frame contains the columns of the two frames involved in the operation for the rows with the same name
.
Note:
The column prefixes specified in the join() call,leftFrame
and rightFrame
.
Parent topic: PgxFrames Tabular Data-Structure