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

Method fillNa

src/danfojs-base/core/series.ts:786–811  ·  view source on GitHub ↗
(value: number | string | boolean, options?: { inplace?: boolean })

Source from the content-addressed store, hash-verified

784 */
785 fillNa(value: number | string | boolean, options?: { inplace?: boolean }): Series
786 fillNa(value: number | string | boolean, options?: { inplace?: boolean }): Series | void {
787 const { inplace } = { inplace: false, ...options }
788
789 if (!value && typeof value !== "boolean" && typeof value !== "number") {
790 throw Error('ParamError: value must be specified');
791 }
792
793 const newValues: ArrayType1D = [];
794 (this.values as ArrayType1D).forEach((val) => {
795 if (utils.isEmpty(val)) {
796 newValues.push(value);
797 } else {
798 newValues.push(val);
799 }
800 });
801
802 if (inplace) {
803 this.$setValues(newValues)
804 } else {
805 return utils.createNdframeFromNewDataWithOldProps({
806 ndFrame: this,
807 newData: newValues,
808 isSeries: true
809 }) as Series
810 }
811 }
812
813
814 /**

Callers

nothing calls this directly

Calls 3

isEmptyMethod · 0.80
$setValuesMethod · 0.80

Tested by

no test coverage detected