* The basic methos perform the underneath operation of generating * the merge dataframe; using the combination keys generated from * bothe left and right DataFrame * e.g df = { * key1: ["KO", "K0", "K3", "K4"], * Key2: ["K1", "K1", "K3", "K5"], * A: [1,2,3,4] * B: [3,4,5,6]
(keys: ArrayType1D, leftKeyDict: keyComb, rightKeyDict: keyComb)
| 235 | * @param rightKeyDict |
| 236 | */ |
| 237 | private basic(keys: ArrayType1D, leftKeyDict: keyComb, rightKeyDict: keyComb): ArrayType2D { |
| 238 | const data = [] |
| 239 | for (let i=0; i < keys.length; i++) { |
| 240 | const key = keys[i] as string |
| 241 | |
| 242 | if (utils.keyInObject(leftKeyDict, key)) { |
| 243 | const leftRows = leftKeyDict[key].filters |
| 244 | const leftCombValues = leftKeyDict[key].combValues |
| 245 | |
| 246 | for (let lIndex=0; lIndex < leftRows.length; lIndex++) { |
| 247 | const leftRow = leftRows[lIndex] |
| 248 | if (utils.keyInObject(rightKeyDict, key)) { |
| 249 | const rightRows = rightKeyDict[key].filters |
| 250 | for (let rIndex=0; rIndex < rightRows.length; rIndex++) { |
| 251 | const rightRow = rightRows[rIndex] |
| 252 | const combineData = leftCombValues.slice(0) |
| 253 | combineData.push(...leftRow) |
| 254 | combineData.push(...rightRow) |
| 255 | data.push(combineData) |
| 256 | } |
| 257 | } else { |
| 258 | const nanArray = Array(this.rightCol?.length).fill(NaN) |
| 259 | const combineData = leftCombValues.slice(0) |
| 260 | combineData.push(...leftRow) |
| 261 | combineData.push(...nanArray) |
| 262 | data.push(combineData) |
| 263 | } |
| 264 | } |
| 265 | } else { |
| 266 | const rightRows = rightKeyDict[key].filters |
| 267 | const rightCombValues = rightKeyDict[key].combValues |
| 268 | |
| 269 | for (let i =0; i < rightRows.length; i++) { |
| 270 | const rightRow = rightRows[i] |
| 271 | const nanArray = Array(this.leftCol?.length).fill(NaN) |
| 272 | const combineData = rightCombValues.slice(0) |
| 273 | combineData.push(...nanArray) |
| 274 | combineData.push(...rightRow) |
| 275 | data.push(combineData) |
| 276 | |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | return data |
| 281 | } |
| 282 | |
| 283 | /** |
| 284 | * Generate outer key from leftKeyDict and rightKeyDict |
no test coverage detected