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

Method applyMap

src/danfojs-base/core/frame.ts:2591–2612  ·  view source on GitHub ↗
(callable: any, options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

2589 */
2590 applyMap(callable: any, options?: { inplace?: boolean }): DataFrame
2591 applyMap(callable: any, options?: { inplace?: boolean }): DataFrame | void {
2592 const { inplace } = { inplace: false, ...options }
2593
2594 const newData = (this.values as ArrayType2D).map((row) => {
2595 const tempData = row.map((val) => {
2596 return callable(val);
2597 });
2598 return tempData;
2599 });
2600
2601 if (inplace) {
2602 this.$setValues(newData);
2603 } else {
2604 return new DataFrame(newData,
2605 {
2606 index: [...this.index],
2607 columns: [...this.columns],
2608 dtypes: [...this.dtypes],
2609 config: { ...this.config }
2610 });
2611 }
2612 }
2613
2614 /**
2615 * Returns the specified column data as a Series object.

Callers

nothing calls this directly

Calls 2

$setValuesMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected