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

Method substring

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

Source from the content-addressed store, hash-verified

640 */
641 substring(startIndex: number, endIndex: number, options?: { inplace?: boolean }): Series
642 substring(startIndex = 0, endIndex = 1, options?: { inplace?: boolean }): Series | void {
643 const { inplace } = { inplace: false, ...options }
644 const newArr: Array<string | number> = [];
645 this.values.map((val) => {
646 if (utils.isEmpty(val)) {
647 newArr.push(NaN);
648 } else {
649 newArr.push(`${String(val).substring(startIndex, endIndex)}`);
650 }
651 });
652 if (inplace) {
653 this.series.$setValues(newArr as ArrayType1D)
654 this.series.print()
655 } else {
656 const sf = this.series.copy()
657 sf.$setValues(newArr as ArrayType1D)
658 return sf;
659 }
660 }
661
662 /**
663 * Removes whitespace from both ends of a string

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