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

Method apply

src/danfojs-base/core/series.ts:1050–1069  ·  view source on GitHub ↗
(callable: (value: any) => any, options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

1048 */
1049 apply(callable: (value: any) => any, options?: { inplace?: boolean }): Series
1050 apply(callable: (value: any) => any, options?: { inplace?: boolean }): Series | void {
1051 const { inplace } = { inplace: false, ...options }
1052
1053 const isCallable = utils.isFunction(callable);
1054 if (!isCallable) {
1055 throw new Error("Param Error: callable must be a function");
1056 }
1057
1058 const data = this.values.map((val) => {
1059 return callable(val);
1060 });
1061
1062 if (inplace) {
1063 this.$setValues(data)
1064 } else {
1065 const sf = this.copy();
1066 sf.$setValues(data)
1067 return sf;
1068 }
1069 }
1070
1071 /**
1072 * Returns a Series with only the unique value(s) in the original Series

Callers

nothing calls this directly

Calls 4

copyMethod · 0.95
isFunctionMethod · 0.80
$setValuesMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected