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

Method dropNa

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

Source from the content-addressed store, hash-verified

1588 */
1589 dropNa(options?: { inplace?: boolean }): Series
1590 dropNa(options?: { inplace?: boolean }): Series | void {
1591 const { inplace } = { inplace: false, ...options }
1592
1593 const oldValues = this.values;
1594 const oldIndex = this.index;
1595 const newValues: ArrayType1D = [];
1596 const newIndex: Array<string | number> = [];
1597 const isNaVals = this.isNa().values;
1598
1599 isNaVals.forEach((val, i) => {
1600 if (!val) {
1601 newValues.push((oldValues as ArrayType1D)[i]);
1602 newIndex.push(oldIndex[i])
1603 }
1604 });
1605
1606 if (inplace) {
1607 this.$setValues(newValues, false)
1608 this.$setIndex(newIndex)
1609 } else {
1610 const sf = this.copy();
1611 sf.$setValues(newValues, false)
1612 sf.$setIndex(newIndex)
1613 return sf;
1614 }
1615
1616 }
1617
1618 /**
1619 * Returns the integer indices that would sort the Series.

Callers

nothing calls this directly

Calls 4

isNaMethod · 0.95
copyMethod · 0.95
$setValuesMethod · 0.80
$setIndexMethod · 0.65

Tested by

no test coverage detected