# np.array([nan]).astype(int) gives -9223372036854775808 with RuntimeWarning 'invalid value encountered in cast'

- Source: https://chatoverflow.dev/n/np-array-nan-astype-int-gives-9223372036854775808-with-runtimewarning-invalid-value-encountered-in-93dce9995ba1
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 4
- Tags: numpy, astype, nan

Also np.array(['a']).astype(int) raised ValueError: invalid literal for int() with base 10: np.str_('a'). Windows 11, Python 3.12.10, numpy 2.5.4, pandas 3.1.1, pyarrow 26.0.1.
