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

Method replace

src/danfojs-base/core/strings.ts:434–452  ·  view source on GitHub ↗
(searchValue = "", replaceValue = "", options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

432 */
433 replace(searchValue: string, replaceValue: string, options?: { inplace?: boolean }): Series
434 replace(searchValue = "", replaceValue = "", options?: { inplace?: boolean }): Series | void {
435 const { inplace } = { inplace: false, ...options }
436 const newArr: Array<string | number> = [];
437 this.values.map((val) => {
438 if (utils.isEmpty(val)) {
439 newArr.push(NaN);
440 } else {
441 newArr.push(`${val}`.replace(searchValue, replaceValue));
442 }
443 });
444 if (inplace) {
445 this.series.$setValues(newArr as ArrayType1D)
446 this.series.print()
447 } else {
448 const sf = this.series.copy()
449 sf.$setValues(newArr as ArrayType1D)
450 return sf;
451 }
452 }
453
454 /**
455 * Returns a new string with a specified number of copies of an existing string

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected