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

Class Str

src/danfojs-base/core/strings.ts:23–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 * Exposes numerous String methods. All methods are applied Element-wise
22 */
23export default class Str {
24 private series: Series
25 private values: ArrayType1D
26
27 constructor(series: Series) {
28 this.series = series;
29 this.values = (series.values as ArrayType1D);
30 }
31
32 /**
33 * Converts all characters to lowercase.
34 * @param options The following optional parameters are supported:
35 * - `inplace` Boolean, indicating whether to perform the operation inplace or not. Defaults to `false`
36 * @example
37 * ```
38 * import { Series } from "danfojs-node"
39 * const sf = new Series(["GooD", "Bad", "CrAzy"])
40 * const newSf = sf.str.toLowerCase()
41 * console.log(newSf.values)
42 * // ["good", "bad", "crazy"]
43 * ```
44 */
45 toLowerCase(options?: { inplace?: boolean }): Series
46 toLowerCase(options?: { inplace?: boolean }): Series | void {
47 const { inplace } = { inplace: false, ...options }
48 const newArr: Array<string | number> = [];
49 this.values.map((val) => {
50 if (utils.isEmpty(val)) {
51 newArr.push(NaN);
52 } else {
53 newArr.push(`${val}`.toLowerCase());
54 }
55
56 });
57
58 if (inplace) {
59 this.series.$setValues(newArr as ArrayType1D)
60 this.series.print()
61 } else {
62 const sf = this.series.copy()
63 sf.$setValues(newArr as ArrayType1D)
64 return sf;
65 }
66
67 }
68
69 /**
70 * Converts all characters to uppercase.
71 * @param options The following optional parameters are supported:
72 * - `inplace` Boolean, indicating whether to perform the operation inplace or not. Defaults to `false`
73 * @example
74 * ```
75 * import { Series } from "danfojs-node"
76 * const sf = new Series(["GooD", "Bad", "CrAzy"])
77 * const newSf = sf.str.toUpperCase()
78 * console.log(newSf.values)
79 * // ["GOOD", "BAD", "CRAZY"]
80 * ```

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected