MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / concat

Method concat

src/danfojs-base/core/strings.ts:196–239  ·  view source on GitHub ↗
(other: Array<string> | string, position = 1, options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

194 */
195 concat(other: Array<string> | string, position: number, options?: { inplace?: boolean }): Series
196 concat(other: Array<string> | string, position = 1, options?: { inplace?: boolean }): Series | void {
197 const { inplace } = { inplace: false, ...options }
198 const newArr: Array<string | number> = [];
199
200 if (Array.isArray(other)) {
201 for (let i = 0; i < other.length; i++) {
202 let leftStr = `${this.values[i]}`;
203 let rightStr = `${other[i]}`;
204 if (position == 1) {
205 newArr.push(leftStr.concat(rightStr));
206 } else {
207 newArr.push(rightStr.concat(leftStr));
208 }
209
210 }
211 } else {
212 this.values.map((val) => {
213 if (position == 1) {
214 if (utils.isEmpty(val)) {
215 newArr.push(NaN);
216 } else {
217 newArr.push(`${val}`.concat(`${other}`));
218 }
219
220 } else {
221 if (utils.isEmpty(val)) {
222 newArr.push(NaN);
223 } else {
224 newArr.push(other.concat(`${val}`));
225 }
226 }
227 });
228 }
229
230 if (inplace) {
231 this.series.$setValues(newArr as ArrayType1D)
232 this.series.print()
233 } else {
234 const sf = this.series.copy()
235 sf.$setValues(newArr as ArrayType1D)
236 return sf;
237 }
238
239 }
240
241
242 /**

Callers 5

strings.test.jsFile · 0.80
series.test.jsFile · 0.80
concat.test.jsFile · 0.80
strings.test.tsFile · 0.80
series.test.tsFile · 0.80

Calls 5

isEmptyMethod · 0.80
$setValuesMethod · 0.80
mapMethod · 0.65
printMethod · 0.65
copyMethod · 0.65

Tested by

no test coverage detected