Replace the Nan values with 0 in Java

Bingo

Hello i need to replace the Nan values with 0 in my array in java, any help thanks. you can find the example of my array.

The array type is double and the contents of array are as follows.

x = [ 1 , 2, Nan , 4, Nan ] 
Gautham M

Loop the array and use isNaN method from Double to check if the number is NaN.

for(int i=0; i<array.length; i++){
    if(Double.isNaN(array[i])) {
        array[i] = 0d;
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Replace 0 with NaN for selected columns only if all values are 0 in Pandas

Replace NaN values in DataFrame

Replace dataframe values by NaN

Replace nan values in a square matrix

Pandas replace values with NaN at random

Merge to replace only nan values

How to replace nan and null values?

Replace empty values of a dictionary with NaN

Replace numerical values with NaN in Python

Replace duplicate set of values with NaN

Pandas dynamically replace nan values

Replace 0 by the last value seen in the array (similar to the fillna method with NaN values) in pandas dataframes

R : how to get rid of all NaN values and replace them by 0 in a complex function / R file

Replace NaN values with interpolation of they near values in matrix

Replace repeating values with 0

Replace negative values in dataframe by NaN, replace NaN with fillna method

MATLAB How to replace real values with NaN and NaN with real values

In pandas replace consecutive 0s with NaN

Replace NaN values in all levels of a Pandas MultiIndex

Replace -ve values in a column as NaN in pandas

Replace other values with np.nan

Python Pandas - Replace NaN values using dict

Replace values in numpy array containing NaN

Replace empty list values in Pandas DataFrame with NaN

How to replace values in a column if another column is a NaN?

Pandas replace change so values to NaN

numpy array: replace nan values with average of columns

pandas DataFrame: replace nan values with average of columns

How to conditionally replace NaN values in a dataframe?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive