I have an array of floats (some normal numbers, some nans) that is coming out of an apply on a pandas dataframe.

For some reason, numpy.isnan is failing on this array, however as shown below, each element is a float, numpy.isnan runs correctly on each element, the type of the variable is definitely a numpy array.

What's going on?!

```
set([type(x) for x in tester])
Out[59]: {float}
tester
Out[60]:
array([-0.7000000000000001, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan], dtype=object)
set([type(x) for x in tester])
Out[61]: {float}
np.isnan(tester)
Traceback (most recent call last):
File "<ipython-input-62-e3638605b43c>", line 1, in <module>
np.isnan(tester)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
set([np.isnan(x) for x in tester])
Out[65]: {False, True}
type(tester)
Out[66]: numpy.ndarray
```

`np.isnan`

can be applied to NumPy arrays of native dtype (such as np.float64):

```
In [99]: np.isnan(np.array([np.nan, 0], dtype=np.float64))
Out[99]: array([ True, False], dtype=bool)
```

but raises TypeError when applied to object arrays:

```
In [96]: np.isnan(np.array([np.nan, 0], dtype=object))
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
```

Since you have Pandas, you could use `pd.isnull`

instead -- it can accept NumPy arrays of object or native dtypes:

```
In [97]: pd.isnull(np.array([np.nan, 0], dtype=float))
Out[97]: array([ True, False], dtype=bool)
In [98]: pd.isnull(np.array([np.nan, 0], dtype=object))
Out[98]: array([ True, False], dtype=bool)
```

Note that `None`

is also considered a null value in object arrays.

- programming a servo thru a barometer
- Is there a way to view two blocks of code from the same file simultaneously in Sublime Text?
- python variable NameError
- Why my regexp for hyphenated words doesn't work?
- Comparing a variable with a string python not working when redirecting from bash script
- is it possible to add colors to python output?
- Get Public URL for File - Google Cloud Storage - App Engine (Python)
- Real time face detection OpenCV, Python
- xlrd.biffh.XLRDError: Excel xlsx file; not supported
- Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation
- Upgrade to python 3.8 using conda
- Unable to allocate array with shape and data type
- How to fix error "ERROR: Command errored out with exit status 1: python." when trying to install django-heroku using pip
- How to prevent Google Colab from disconnecting?
- "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm
- How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function?
- "E: Unable to locate package python-pip" on Ubuntu 18.04
- Tensorflow 2.0 - AttributeError: module 'tensorflow' has no attribute 'Session'
- Jupyter Notebook not saving: '_xsrf' argument missing from post
- How to Install pip for python 3.7 on Ubuntu 18?
- Python: 'ModuleNotFoundError' when trying to import module from imported package
- OpenCV TypeError: Expected cv::UMat for argument 'src' - What is this?
- Requests (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.") Error in PyCharm requesting website
- How to setup virtual environment for Python in VS Code?
- Pylint "unresolved import" error in Visual Studio Code
- Pandas Merging 101
- Numpy, multiply array with scalar
- What is the meaning of "Failed building wheel for X" in pip install?
- Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed
- Could not install packages due to an EnvironmentError: [Errno 13]
- OpenCV !_src.empty() in function 'cvtColor' error
- ConvergenceWarning: Liblinear failed to converge, increase the number of iterations
- How to downgrade python from 3.7 to 3.6
- I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."?
- Iterating over arrays in Python 3
- How do I install opencv using pip?
- How do I install Python packages in Google's Colab?
- How do I use TensorFlow GPU?
- How to upgrade Python version to 3.7?
- How to resolve TypeError: can only concatenate str (not "int") to str
- How can I install a previous version of Python 3 in macOS using homebrew?
- Flask at first run: Do not use the development server in a production environment
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- What is the difference between Jupyter Notebook and JupyterLab?
- Pytesseract : "TesseractNotFound Error: tesseract is not installed or it's not in your path", how do I fix this?
- Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"
- How do I resolve a TesseractNotFoundError?
- Trying to merge 2 dataframes but get ValueError
- Authentication plugin 'caching_sha2_password' is not supported
- Python Pandas User Warning: Sorting because non-concatenation axis is not aligned
- [Move to Numpy isnan() fails on an array of floats (from pandas dataframe apply)]

- PHP array value passes to next row
- Use NSInteger as array index
- How do I show a message in the foreach loop?
- Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
- Iterating over arrays in Python 3
- Best way to "push" into C# array
- Sort Array of object by object field in Angular 6
- Checking for duplicate strings in JavaScript array
- what does numpy ndarray shape do?
- How to round a numpy array?
- How to update an "array of objects" with Firestore?
- How to increment a letter N times per iteration and store in an array?
- Cloning an array in Javascript/Typescript
- use Lodash to sort array of object by value
- TypeScript enum to object array
- How do I check whether an array contains a string in TypeScript?
- How to use forEach in vueJs?
- Program to find largest and second largest number in array
- How to plot an array in python?
- How to add and remove item from array in components in Vue 2
- console.log(result) returns [object Object]. How do I get result.name?
- How to map an array of objects in React
- How to define Typescript Map of key value pair. where key is a number and value is an array of objects
- Removing object from array in Swift 3
- How to group an array of objects by key
- Find object by its property in array of objects with AngularJS way
- Getting an object array from an Angular service
- push object into array
- How to get first and last element in an array in java?
- Add key value pair to all objects in array
- How to convert array into comma separated string in javascript
- Showing ValueError: shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)
- Angular 2 declaring an array of objects
- How can I loop through enum values for display in radio buttons?
- How to convert JSON object to an Typescript array?
- Angular get object from array by Id
- Add property to an array of objects
- Declare an array in TypeScript
- ValueError: all the input arrays must have same number of dimensions
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- Check if a value is in an array or not with Excel VBA
- TypeScript add Object to array with push
- Filter array to have unique values
- remove first element from array and return the array minus the first element
- merge two object arrays with Angular 2 and TypeScript?
- Creating an Array from a Range in VBA
- "error: assignment to expression with array type error" when I assign a struct field (C)
- How do I filter an array with TypeScript in Angular 2?
- How to generate range of numbers from 0 to n in ES2015 only?
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- [Move to Numpy isnan() fails on an array of floats (from pandas dataframe apply)]

- Unable to allocate array with shape and data type
- How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function?
- Numpy, multiply array with scalar
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"
- Pytorch tensor to numpy array
- Numpy Resize/Rescale Image
- what does numpy ndarray shape do?
- How to round a numpy array?
- numpy array TypeError: only integer scalar arrays can be converted to a scalar index
- Convert np.array of type float64 to type uint8 scaling values
- How to import cv2 in python3?
- How to calculate 1st and 3rd quartiles?
- Counting unique values in a column in pandas dataframe like in Qlik?
- Binning column with python pandas
- convert array into DataFrame in Python
- How to change a single value in a NumPy array?
- 'DataFrame' object has no attribute 'sort'
- ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
- Pytorch reshape tensor dimension
- Python "TypeError: unhashable type: 'slice'" for encoding categorical data
- len() of a numpy array in python
- ValueError: cannot reshape array of size 30470400 into shape (50,1104,104)
- Python - AttributeError: 'numpy.ndarray' object has no attribute 'append'
- How to plot vectors in python using matplotlib
- How to plot an array in python?
- TypeError: 'DataFrame' object is not callable
- LogisticRegression: Unknown label type: 'continuous' using sklearn in python
- Python Pandas - Missing required dependencies ['numpy'] 1
- Pandas Split Dataframe into two Dataframes at a specific row
- What does 'index 0 is out of bounds for axis 0 with size 0' mean?
- What is the difference between i = i + 1 and i += 1 in a 'for' loop?
- Get index of a row of a pandas dataframe as an integer
- FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison
- TensorFlow ValueError: Cannot feed value of shape (64, 64, 3) for Tensor u'Placeholder:0', which has shape '(?, 64, 64, 3)'
- How to get element-wise matrix multiplication (Hadamard product) in numpy?
- Showing ValueError: shapes (1,3) and (1,3) not aligned: 3 (dim 1) != 1 (dim 0)
- Pandas: convert dtype 'object' to int
- ValueError: all the input arrays must have same number of dimensions
- Numpy: Checking if a value is NaT
- How to split data into 3 sets (train, validation and test)?
- Pandas: Subtracting two date columns and the result being an integer
- How to get the indices list of all NaN value in numpy array?
- What is dtype('O'), in pandas?
- ImportError: cannot import name NUMPY_MKL
- why numpy.ndarray is object is not callable in my simple for python loop
- How to convert numpy arrays to standard TensorFlow format?
- ValueError when checking if variable is None or numpy.array
- TypeError: only length-1 arrays can be converted to Python scalars while plot showing
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- [Move to Numpy isnan() fails on an array of floats (from pandas dataframe apply)]

- xlrd.biffh.XLRDError: Excel xlsx file; not supported
- Pandas Merging 101
- How to increase image size of pandas.DataFrame.plot in jupyter notebook?
- Trying to merge 2 dataframes but get ValueError
- Python Pandas User Warning: Sorting because non-concatenation axis is not aligned
- How to show all of columns name on pandas dataframe?
- Pandas/Python: Set value of one column based on value in another column
- Python Pandas - Find difference between two data frames
- Pandas get the most frequent values of a column
- Python convert object to float
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- Pandas: ValueError: cannot convert float NaN to integer
- How to create a stacked bar chart for my DataFrame using seaborn?
- LabelEncoder: TypeError: '>' not supported between instances of 'float' and 'str'
- Display/Print one column from a DataFrame of Series in Pandas
- How to calculate 1st and 3rd quartiles?
- Counting unique values in a column in pandas dataframe like in Qlik?
- Binning column with python pandas
- convert array into DataFrame in Python
- Selection with .loc in python
- Set value to an entire column of a pandas dataframe
- Pandas create empty DataFrame with only column names
- Python: pandas merge multiple dataframes
- 'DataFrame' object has no attribute 'sort'
- Remove Unnamed columns in pandas dataframe
- Convert float64 column to int64 in Pandas
- Understanding inplace=True
- How to select rows with NaN in particular column?
- How to print a specific row of a pandas DataFrame?
- Pandas rename column by position?
- re.sub erroring with "Expected string or bytes-like object"
- Python Pandas iterate over rows and access column names
- Display rows with one or more NaN values in pandas dataframe
- Python "TypeError: unhashable type: 'slice'" for encoding categorical data
- Seaborn Barplot - Displaying Values
- ValueError: Wrong number of items passed - Meaning and suggestions?
- How to get row number in dataframe in Pandas?
- How to install pandas from pip on windows cmd?
- Pandas convert string to int
- Convert list into a pandas data frame
- Use .corr to get the correlation between two columns
- Why isn't this code to plot a histogram on a continuous value Pandas column working?
- How to add title to seaborn boxplot
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- How to save a new sheet in an existing excel file, using Pandas?
- matplotlib: plot multiple columns of pandas data frame on the bar chart
- Convert List to Pandas Dataframe Column
- TypeError: 'DataFrame' object is not callable
- Set order of columns in pandas dataframe
- Python Pandas - Missing required dependencies ['numpy'] 1
- [Move to Numpy isnan() fails on an array of floats (from pandas dataframe apply)]