np.int64 is NumPy’s 64-bit integer dtype, commonly used by pandas for integer Series. Pandas normally selects it when every Series value is an integer. section 1.5
Use np.int64 when you need to make the intended integer dtype explicit:
- Create a Series with dtype=np.int64 instead of relying on pandas’ automatic choice. section 1.5
- Convert an existing Series with astype(np.int64), then inspect its dtype. section 1.5
- Check dtype deliberately when working with large datasets, where memory usage and accuracy matter. section 1.5
Converting a Series to np.int64
s = Series('10 20 30'.split()) s = s.astype(np.int64) s.dtype section 1.5
A data-integration exercise
Require a tourism DataFrame’s Value column to have dtype=np.int64 before reproducing earlier joins with merge, then compare merge’s default NaN behavior with join’s. section 7.16
