danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

Replacing a value with 0 with dataframe.replace throws an error

Open Ren-Logronio opened this issue 2 years ago • 2 comments

DataFrame.prototype.replace = function (oldValue, newValue, options) { var _this = this; var _a = __assign({ inplace: false }, options), columns = _a.columns, inplace = _a.inplace; if (!oldValue && typeof oldValue !== 'boolean') { throw Error("Params Error: Must specify param 'oldValue' to replace"); } if (!newValue && typeof newValue !== 'boolean') { throw Error("Params Error: Must specify param 'newValue' to replace with"); } <--- this is true for newValue = 0..

I do not see why this is intentional given that the nature of the error is that I specify a newValue to replace an old value. And thats what I was intending to do, to replace values to 0.

Ren-Logronio avatar Dec 16 '23 23:12 Ren-Logronio

I encountered the same issue when replacing a value with NaN

this.df.replace('-', NaN)

Reaganak40 avatar Apr 19 '24 18:04 Reaganak40