MCPcopy Create free account
hub / github.com/javascriptdata/danfojs / createColumns

Method createColumns

src/danfojs-base/transformers/merge.ts:139–164  ·  view source on GitHub ↗

* Generate columns for the newly generated merged DataFrame * e.g df = { * key1: ["KO", "K0", "K3", "K4"], * Key2: ["K1", "K1", "K3", "K5"], * A: [1,2,3,4] * B: [3,4,5,6] * } * df2 = { * key1: ["KO", "K0", "K3", "K4"], * Key2: ["K1", "K1", "K3", "K5"], * A: [1,2,

()

Source from the content-addressed store, hash-verified

137 * number of duplicate of that column
138 */
139 private createColumns() {
140 const self = this
141 this.leftCol = self.left.columns.filter((_, index)=>{
142 return !self.leftColIndex.includes(index)
143 })
144 this.rightCol = self.right.columns.filter((_, index) => {
145 return !self.rightColIndex.includes(index)
146 })
147 this.columns = [...this.on]
148 const duplicateColumn: {
149 [key: string] : number
150 } = {}
151 const tempColumn = [...this.leftCol]
152 tempColumn.push(...this.rightCol)
153 for (let i=0; i< tempColumn.length; i++) {
154 const col = tempColumn[i] as string
155 if (utils.keyInObject(duplicateColumn, col)) {
156 let columnName = `${col}_${duplicateColumn[col]}`
157 this.columns.push(columnName)
158 duplicateColumn[col] +=1
159 } else {
160 this.columns.push(col)
161 duplicateColumn[col] = 1
162 }
163 }
164 }
165
166 /**
167 * The basic methos perform the underneath operation of generating

Callers 1

operationMethod · 0.95

Calls 2

includesMethod · 0.80
keyInObjectMethod · 0.80

Tested by

no test coverage detected