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

Method capitalize

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

Source from the content-addressed store, hash-verified

117 */
118 capitalize(options?: { inplace?: boolean }): Series
119 capitalize(options?: { inplace?: boolean }): Series | void {
120 const { inplace } = { inplace: false, ...options }
121 const newArr: Array<string | number> = [];
122 this.values.map((val) => {
123 if (utils.isEmpty(val)) {
124 newArr.push(NaN);
125 } else {
126 let firstChar = `${val}`.slice(0, 1);
127 let leftChar = `${val}`.slice(1);
128 let newStr = `${firstChar.toUpperCase()}${leftChar.toLowerCase()}`;
129 newArr.push(newStr);
130 }
131
132 });
133
134 if (inplace) {
135 this.series.$setValues(newArr as ArrayType1D)
136 this.series.print()
137 } else {
138 const sf = this.series.copy()
139 sf.$setValues(newArr as ArrayType1D)
140 return sf;
141 }
142
143 }
144
145 /**
146 * Returns the character at the specified index (position)

Callers 4

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

Calls 8

isEmptyMethod · 0.80
sliceMethod · 0.80
toUpperCaseMethod · 0.80
toLowerCaseMethod · 0.80
$setValuesMethod · 0.80
mapMethod · 0.65
printMethod · 0.65
copyMethod · 0.65

Tested by

no test coverage detected