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

Method substr

src/danfojs-base/core/strings.ts:608–626  ·  view source on GitHub ↗
(startIndex = 0, num = 1, options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

606 */
607 substr(startIndex: number, num: number, options?: { inplace?: boolean }): Series
608 substr(startIndex = 0, num = 1, options?: { inplace?: boolean }): Series | void {
609 const { inplace } = { inplace: false, ...options }
610 const newArr: Array<string | number> = [];
611 this.values.map((val) => {
612 if (utils.isEmpty(val)) {
613 newArr.push(NaN);
614 } else {
615 newArr.push(`${String(val).substr(startIndex, num)}`);
616 }
617 });
618 if (inplace) {
619 this.series.$setValues(newArr as ArrayType1D)
620 this.series.print()
621 } else {
622 const sf = this.series.copy()
623 sf.$setValues(newArr as ArrayType1D)
624 return sf;
625 }
626 }
627
628 /**
629 * Extracts the characters from a string, between two specified indices

Callers 2

strings.test.jsFile · 0.80
strings.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