numpy.ndarray.tolist will do it:

a.tolist()

If your data is a pandas series you can call their tolist wrapper with the same result.

Answer from bigonazzi on Stack Overflow
🌐
GitHub
github.com › pandas-dev › pandas › issues › 16048
to_dict doesn't convert np.int64 to python integers · Issue #16048 · pandas-dev/pandas
April 18, 2017 - # Your code here data = [{'id': 11, 'text': 'Osv1wbZoL'}, {'id': 0, 'text': 'KQpPReW3S9nZOS3'}, {'id': 0, 'text': 'cbqLhjrb0B2Ah6E'}, {'id': 3, 'text': 'qu1Jlnyba'}, {'id': 14, 'text': 'aJUv5DBjbcGc3'}, {'id': 12, 'text': 'Yobf9'}, {'id': 4, 'text': 'awzZCV'}, {'id': 4, 'text': '3NvBAVL'}, {'id': 11, 'text': '80sPCxIf9s5wmEZ1'}, {'id': 5, 'text': 'afrPD0X6mIzFK'}] df = pd.DataFrame(data) # out: # id int64 # text object # dtype: object type(df[['id', 'text']].to_dict(orient='records')[0]['id']) # out: int type(df[['id']].to_dict(orient='records')[0]['id']) # out: numpy.int64 · depending on the
Author   kszucs
Discussions

Convert numpy.int64 to python int in pandas - Stack Overflow
I have an excel file with one sheet. This contains two columns num1, num2 and both of them has integer values. I'm trying to pull this data and insert it into Mysql database using Sqlalchemy and pa... More on stackoverflow.com
🌐 stackoverflow.com
September 21, 2017
python - Convert float64 column to int64 in Pandas - Stack Overflow
Or use np.int64 directly on your column (but it returns a numpy.array): ... @MCGCode That's not so good, because NaNs can't be converted to integers (at least not with a meaningful value because only floats support NaN and Inf). What value should these have in the result? More on stackoverflow.com
🌐 stackoverflow.com
Converting numpy dtypes to native python types - Stack Overflow
If I have a numpy dtype, how do I automatically convert it to its closest python data type? For example, numpy.float32 -> "python float" numpy.float64 -> "python float" numpy.uint32 -> " More on stackoverflow.com
🌐 stackoverflow.com
Trying to convert an Int64Index to an Int
Hello! I am trying to refer to an index value as an integer. Does anyone know how to do this? index_value = data.index[data.timestamp == int(slice_end_timestamp)] My desired output is ‘220289’ Current output is: ‘Int64Index([220289], dtype=‘int64’)’ Thank you in advance. More on discuss.python.org
🌐 discuss.python.org
4
0
June 25, 2022
🌐
Zditect
zditect.com › blog › 56853418.html
Numpy array int64 to int
We cannot provide a description for this page right now
🌐
Google Groups
groups.google.com › g › numpy › c › 6nCcuw3NkKw
[Numpy-discussion] PyInt and Numpy's int64 conversion
I want to convert a numpy array of integers (whose elements are numpy's 'int64') The problem is that it this int64 type is not compatible with the standard python integer type: I cannot use PyInt_Check, and PyInt_AsUnsignedLongMask to check and convert from int64: basically PyInt_Check returns ...
Top answer
1 of 5
125

Solution for pandas 0.24+ for converting numeric with missing values:

df = pd.DataFrame({'column name':[7500000.0,7500000.0, np.nan]})
print (df['column name'])
0    7500000.0
1    7500000.0
2          NaN
Name: column name, dtype: float64

df['column name'] = df['column name'].astype(np.int64)

ValueError: Cannot convert non-finite values (NA or inf) to integer

#http://pandas.pydata.org/pandas-docs/stable/user_guide/integer_na.html
df['column name'] = df['column name'].astype('Int64')
print (df['column name'])
0    7500000
1    7500000
2        NaN
Name: column name, dtype: Int64

I think you need cast to numpy.int64:

df['column name'].astype(np.int64)

Sample:

df = pd.DataFrame({'column name':[7500000.0,7500000.0]})
print (df['column name'])
0    7500000.0
1    7500000.0
Name: column name, dtype: float64

df['column name'] = df['column name'].astype(np.int64)
#same as
#df['column name'] = df['column name'].astype(pd.np.int64)
print (df['column name'])
0    7500000
1    7500000
Name: column name, dtype: int64

If some NaNs in columns need replace them to some int (e.g. 0) by fillna, because type of NaN is float:

df = pd.DataFrame({'column name':[7500000.0,np.nan]})

df['column name'] = df['column name'].fillna(0).astype(np.int64)
print (df['column name'])
0    7500000
1          0
Name: column name, dtype: int64

Also check documentation - missing data casting rules

EDIT:

Convert values with NaNs is buggy:

df = pd.DataFrame({'column name':[7500000.0,np.nan]})

df['column name'] = df['column name'].values.astype(np.int64)
print (df['column name'])
0                7500000
1   -9223372036854775808
Name: column name, dtype: int64
2 of 5
12

You can need to pass in the string 'int64':

>>> import pandas as pd
>>> df = pd.DataFrame({'a': [1.0, 2.0]})  # some test dataframe

>>> df['a'].astype('int64')
0    1
1    2
Name: a, dtype: int64

There are some alternative ways to specify 64-bit integers:

>>> df['a'].astype('i8')      # integer with 8 bytes (64 bit)
0    1
1    2
Name: a, dtype: int64

>>> import numpy as np
>>> df['a'].astype(np.int64)  # native numpy 64 bit integer
0    1
1    2
Name: a, dtype: int64

Or use np.int64 directly on your column (but it returns a numpy.array):

>>> np.int64(df['a'])
array([1, 2], dtype=int64)
🌐
Folkstalk
folkstalk.com › home › technology articles collection
Technology Articles Collection
July 3, 2025 - Skip to content · Technology Articles Collection · Coming Soon · Popular Posts · Joiner Transformation in Informatica · Dell Boomi Architecture Overview · Transaction Control Transformation in Informatica · Awk Command in Unix With Examples · Salesforce Batch Apex Job With Examples ...
🌐
w3resource
w3resource.com › python-exercises › numpy › basic › numpy-basic-exercise-41.php
NumPy: Convert numpy dtypes to native python types - w3resource
August 28, 2025 - This problem involves writing a NumPy program to convert NumPy data types (dtypes) to native Python types. The task requires using NumPy's type conversion functions to transform NumPy-specific data types, such as numpy.int32 or numpy.float32, into their equivalent native Python types, like int or float.
Find elsewhere
Top answer
1 of 13
573

Use val.item() to convert most NumPy values to a native Python type:

import numpy as np

# for example, numpy.float32 -> python float
val = np.float32(0)
pyval = val.item()
print(type(pyval))         # <class 'float'>

# and similar...
type(np.float64(0).item()) # <class 'float'>
type(np.uint32(0).item())  # <class 'int'>
type(np.int16(0).item())   # <class 'int'>
type(np.cfloat(0).item())  # <class 'complex'>
type(np.datetime64(0, 'D').item())  # <class 'datetime.date'>
type(np.datetime64('2001-01-01 00:00:00').item())  # <class 'datetime.datetime'>
type(np.timedelta64(0, 'D').item()) # <class 'datetime.timedelta'>
...

(A related method np.asscalar(val) was deprecated with 1.16, and removed with 1.23).


For the curious, to build a table of conversions of NumPy array scalars for your system:

for name in dir(np):
    obj = getattr(np, name)
    if hasattr(obj, 'dtype'):
        try:
            if 'time' in name:
                npn = obj(0, 'D')
            else:
                npn = obj(0)
            nat = npn.item()
            print('{0} ({1!r}) -> {2}'.format(name, npn.dtype.char, type(nat)))
        except:
            pass

There are a few NumPy types that have no native Python equivalent on some systems, including: clongdouble, clongfloat, complex192, complex256, float128, longcomplex, longdouble and longfloat. These need to be converted to their nearest NumPy equivalent before using .item().

2 of 13
45

If you want to convert (numpy.array OR numpy scalar OR native type OR numpy.darray) TO native type you can simply do :

converted_value = getattr(value, "tolist", lambda: value)()

tolist will convert your scalar or array to python native type. The default lambda function takes care of the case where value is already native.

🌐
Reddit
reddit.com › r/learnpython › how to convert python int into numpy.int64?
r/learnpython on Reddit: How to convert python int into numpy.int64?
October 11, 2017 -

Given a variable in python of type int, e.g.

z = 50
type(z) 
## outputs <class 'int'>

is there a straightforward way to convert this variable into numpy.int64?

It appears one would have to convert this variable into a numpy array, and then convert this into int64. That feels quite convoluted.

https://docs.scipy.org/doc/numpy-1.13.0/user/basics.types.html

🌐
CopyProgramming
copyprogramming.com › howto › python-converting-an-numpy-array-data-type-from-int64-to-int
Python: Converting the data type of a numpy array from int64 to int in Python
July 13, 2023 - My initial assumption was that I could easily utilize the int() function for the conversion, but unfortunately, it didn't work. I would greatly appreciate any suggestions. Thank you in advance. ... If you have a pandas series as your data, you can achieve the same outcome by utilizing their tolist wrapper. ... To handle the numpy.int64 object, follow the item() approach, which was previously discussed in a similar question by Mike T.
🌐
LinuxTut
linuxtut.com › en › 2253e32c22e81e688ef4
Convert numpy int64 to python int
October 24, 2020 - import numpy as np #numpy int64 np_int = np.int64(0) print(type(np_int)) # <class 'numpy.int64'> #Convert to python int py_int = np_int.item() print(type(py_int)) # <class 'int'>
🌐
Pandas
pandas.pydata.org › docs › user_guide › integer_na.html
Nullable integer data type — pandas documentation - PyData |
This is an extension type implemented within pandas. In [1]: arr = pd.array([1, 2, None], dtype=pd.Int64Dtype()) In [2]: arr Out[2]: <IntegerArray> [1, 2, <NA>] Length: 3, dtype: Int64 · Or the string alias "Int64" (note the capital "I") to differentiate from NumPy’s 'int64' dtype:
🌐
Medium
medium.com › @amit25173 › different-ways-to-convert-numpy-float-to-int-f47f3be42453
Different Ways to Convert NumPy Float to Int | by Amit Yadav | Medium
April 12, 2025 - ✅ For regular-sized data → Use .astype(int) (fast and simple). ✅ For large datasets → Stick to vectorized operations (avoid loops). ✅ For large numbers → Convert to np.int64 to prevent overflow.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-convert-a-float64-column-to-int64-in-pandas
How to Convert a Float64 Column to Int64 in Pandas | Saturn Cloud Blog
January 25, 2024 - Another reason to convert a float64 column to an int64 column is for compatibility with other functions or libraries. Some functions or libraries may only accept integer data types, so converting your data to int64 can make it easier to work with. Now that we’ve covered the basics, let’s dive into the conversion process. The process is actually quite simple in Pandas.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.2 documentation - PyData |
Cast a numpy array to a specified type. ... Convert dtypes. ... >>> s = pd.Series(["1.0", "2", -3]) >>> pd.to_numeric(s) 0 1.0 1 2.0 2 -3.0 dtype: float64 >>> pd.to_numeric(s, downcast="float") 0 1.0 1 2.0 2 -3.0 dtype: float32 >>> pd.to_numeric(s, downcast="signed") 0 1 1 2 2 -3 dtype: int8 >>> s = pd.Series(["apple", "1.0", "2", -3]) >>> pd.to_numeric(s, errors="coerce") 0 NaN 1 1.0 2 2.0 3 -3.0 dtype: float64