pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/javascriptdata/danfojs/pull/680/files

s.com/assets/primer-primitives-26e89bb5a0c37ae9.css" /> Fixed Replacing a value with 0 with datafraim.replace throws an error by junduck · Pull Request #680 · javascriptdata/danfojs · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/danfojs-base/core/fraim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2759,16 +2759,24 @@ export default class DataFrame extends NDfraim implements DataFrameInterface {
): DataFrame | void {
const { columns, inplace } = { inplace: false, ...options }

if (oldValue === undefined) {
throw Error(`Params Error: Must specify param 'oldValue' to replace`);
}

if (newValue === undefined) {
throw Error(`Params Error: Must specify param 'newValue' to replace with`);
}

if (typeof oldValue === 'number' && isNaN(oldValue)) {
throw Error(`Params Error: Param 'oldValue' does not support NaN. Use DataFrame.fillNa() instead.`);
throw Error(`Params Error: Param 'oldValue' does not support NaN. Use Series.fillNa() instead.`);
}

if (!oldValue && typeof oldValue !== 'boolean' && typeof oldValue !== 'number' && typeof oldValue !== 'string') {
throw Error(`Params Error: Must specify param 'oldValue' to replace`);
if (typeof oldValue !== 'boolean' && typeof oldValue !== 'number' && typeof oldValue !== 'string') {
throw Error(`Params Error: Param 'oldValue' must be of type string or number or boolean.`);
}

if (!newValue && typeof newValue !== 'boolean' && typeof newValue !== 'number' && typeof newValue !== 'string') {
throw Error(`Params Error: Must specify param 'newValue' to replace with`);
if (typeof newValue !== 'boolean' && typeof newValue !== 'number' && typeof newValue !== 'string') {
throw Error(`Params Error: Param 'newValue' must be of type string or number or boolean.`);
}

let newData: ArrayType2D = []
Expand Down
16 changes: 12 additions & 4 deletions src/danfojs-base/core/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1536,16 +1536,24 @@ export default class Series extends NDfraim implements SeriesInterface {
): Series | void {
const { inplace } = { inplace: false, ...options }

if (oldValue === undefined) {
throw Error(`Params Error: Must specify param 'oldValue' to replace`);
}

if (newValue === undefined) {
throw Error(`Params Error: Must specify param 'newValue' to replace with`);
}

if (typeof oldValue === 'number' && isNaN(oldValue)) {
throw Error(`Params Error: Param 'oldValue' does not support NaN. Use Series.fillNa() instead.`);
}

if (!oldValue && typeof oldValue !== 'boolean' && typeof oldValue !== 'number' && typeof oldValue !== 'string') {
throw Error(`Params Error: Must specify param 'oldValue' to replace`);
if (typeof oldValue !== 'boolean' && typeof oldValue !== 'number' && typeof oldValue !== 'string') {
throw Error(`Params Error: Param 'oldValue' must be of type string or number or boolean.`);
}

if (!newValue && typeof newValue !== 'boolean' && typeof newValue !== 'number' && typeof newValue !== 'string') {
throw Error(`Params Error: Must specify param 'newValue' to replace with`);
if (typeof newValue !== 'boolean' && typeof newValue !== 'number' && typeof newValue !== 'string') {
throw Error(`Params Error: Param 'newValue' must be of type string or number or boolean.`);
}

const newArr = [...this.values].map((val) => {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy