Last active
September 5, 2022 07:47
-
-
Save c0ldlimit/4287824 to your computer and use it in GitHub Desktop.
Converting None to NaN in numpy when casting a list to numpy arrays #numpy #c0ldlimit #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
x = array([3,4,None,55]) | |
y = np.array(x,dtype=float) | |
# OR | |
y = np.array(x) | |
z = y.astype(float) |
I got here while looking for the reverse operation. It can be done like this: u = np.where(np.isnan(y), None, y).tolist()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this was just what i was looking for ;)