Calculate min of rows ignoring NaN values

user3654650

For example, I have this array and calculate mean of rows:

a = np.array([[1,2,3],[2,np.NaN,4]])

mins = np.min(a, axis = 1)

The problem is the output is: [1. nan]. How to ignore nan in a and get result [1 2]?

lejlot

You can use masked arrays

mins = list(np.min(np.ma.masked_array(a, np.isnan(a)), axis=1))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Calculate Number of Rows containg NaN values

Calculate the mean across rows excluding min and max values?

Keras fitting ignoring nan values

2-d interpolation ignoring nan values

Merging dataframes in pandas while ignoring NaN values

Calculate the mode whilst ignoring certain values

How to calculate median while ignoring negative values?

calculate the average by ignoring the 0 values in column

Calculate cumsum() while ignoring NA values

Calculate the sum of values replacing NaN

COUNTIFS ignoring rows based on values in row

How to calculate min and max of a column for particular rows?

How to sum a series of values, ignoring any NaN values?

Sort rows and removing NaN values

Python Dataframe rowwise min and max with NaN values

Googlesheets - ArrayFormula to calculate the weighted average of two rows ignoring text cells

Iterate over rows and calculate values

Pyspark - compute min after group by ignoring null values

Iterating through a nested list to produce min and max values ignoring NoneType

Conditionally Calculate Max and Min Values of a Column

Calculate max, min and mean values of element in an array

Calculate min / max of two values in Less

Ignoring NaN/null values while looping through data

Mean computation from accumulated row values while ignoring NaN in MATLAB

How to compute the mean and standard deviation of columns ignoring NaN values

Calculate cummean() and cumsd() while ignoring NA values and filling NAs

Calculate average of 4 numbers ignoring null values in SQL

Retrieve the rows of data-frames with NAN values and not NAN values

selecting rows with min and max values in pandas dataframe