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

Method trim

src/danfojs-base/core/strings.ts:675–693  ·  view source on GitHub ↗
(options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

673 */
674 trim(options?: { inplace?: boolean }): Series
675 trim(options?: { inplace?: boolean }): Series | void {
676 const { inplace } = { inplace: false, ...options }
677 const newArr: Array<string | number> = [];
678 this.values.map((val) => {
679 if (utils.isEmpty(val)) {
680 newArr.push(NaN);
681 } else {
682 newArr.push(`${val}`.trim());
683 }
684 });
685 if (inplace) {
686 this.series.$setValues(newArr as ArrayType1D)
687 this.series.print()
688 } else {
689 const sf = this.series.copy()
690 sf.$setValues(newArr as ArrayType1D)
691 return sf;
692 }
693 }
694
695 /**
696 * Joins strings to specified value

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