Use .astype.

>>> a = numpy.array([1, 2, 3, 4], dtype=numpy.float64)
>>> a
array([ 1.,  2.,  3.,  4.])
>>> a.astype(numpy.int64)
array([1, 2, 3, 4])

See the documentation for more options.

Answer from kennytm on Stack Overflow
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)
Discussions

problems when converting data from float64 to int64 in python for cross validation
I was preparing data for testing one of the training models, but the key attribute "rating" is in float64 format, but the cross validation only needs int, I tried to tr More on sololearn.com
๐ŸŒ sololearn.com
5
0
python - convert number from numpy.float64 to integer - Stack Overflow
I have the following dataframe: edad id_tipo_propiedad 0 NaN 2 1 NaN 2 2 NaN 2 3 NaN 2 4 NaN ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python 3.x - Converting float64 to integer - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I want to convert a float64 column to integer. More on stackoverflow.com
๐ŸŒ stackoverflow.com
August 18, 2021
Int too large
Look up Python's decimal module More on reddit.com
๐ŸŒ r/learnpython
9
0
October 30, 2022
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ how-to-convert-float64-columns-to-int64-in-pandas
How to Convert float64 Columns to int64 in Pandas? - GeeksforGeeks
July 23, 2025 - import pandas as pd data = {'A': [1.0, 2.4, 3.0], 'B': [4.0, 5.0, 6.5]} print("Before converting") print(df.dtypes) # Use apply method to convert Pandas columns to int df_int = df.apply(lambda column: column.astype(int)) # Check the data types of columns print("\nAfter converting") print(df_int.dtypes) ... As you can observe the float64 values in the dataset are converted to int64 datatype.
๐ŸŒ
AskPython
askpython.com โ€บ python-modules โ€บ pandas โ€บ convert-float64-to-int64
How to Convert float64 Columns to int64 in Pandas? - AskPython
February 27, 2023 - It has a pretty straightforward syntax in which one ought to specify the column name for which the data type is to be converted which in this case would be from foat64 to int64. It is evident from the data types displayed previously that the columns โ€˜Work hrsโ€™ & โ€˜Salaryโ€™ have the float64 data type.
๐ŸŒ
Medium
tmlb-blog-ltd.medium.com โ€บ to-convert-a-float64-type-column-into-an-int64-or-string-type-column-in-python-short-984537c97a63
To convert a float64-type column into an int64 or string-type column in python (short) | by T Miyamoto | Medium
August 20, 2020 - But this causes error messages like TypeError: Cannot cast array from dtype(โ€˜float64โ€™) to dtype(โ€˜int64โ€™) according to the rule โ€˜safe'. So we now resort to the apply clause (although it can be slow): df_a['coli']= (df_a['colf'].apply(lambda w0: None if pd.isnull(w0) else np.int64(w0)) ).astype(pd.Int64Dtype()) ... Next we create a string type column based on column colf. It is well known that astype(str) converts NaN into a string โ€˜nanโ€™. We try to do
๐ŸŒ
YouTube
youtube.com โ€บ the debug zone
How to Convert float64 to int64 in Pandas: A Step-by-Step Guide - YouTube
In this video, weโ€™ll explore a common data manipulation task in Python using the Pandas library: converting float64 data types to int64. Whether you're clean...
Published: September 13, 2024
Views: 28
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 71593052 โ€บ convert-number-from-numpy-float64-to-integer
python - convert number from numpy.float64 to integer - Stack Overflow
So you can use df.edad.astype('Int64') ... it is not possible to convert from numpy.float64 to integer, first it is necessary to fill NaN values and then transform....
Find elsewhere
๐ŸŒ
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
May 1, 2026 - Pandas, a widely used Python library for data analysis and manipulation, offers a range of functions to facilitate the cleaning and transformation of data. A typical operation involves converting a float64 column to an int64 column, and in the following article, we'll delve into the steps to ...
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to fix: โ€˜numpy.float64โ€™ object cannot be interpreted as an integer
How to Fix: 'numpy.float64' object cannot be interpreted as an integer
October 5, 2021 - By using the int() function, we convert each float value in the NumPy array to an integer so we avoid the TypeError we encountered earlier.
๐ŸŒ
Medium
medium.com โ€บ @amit25173 โ€บ pandas-float-to-int-a-practical-guide-a288ab2fe3d9
Pandas Float to Int: A Practical Guide | by Amit Yadav | Medium
March 6, 2025 - A float64 A_int_downcast int8 # Automatically optimized memory usage ยท ๐Ÿ’ก Why this matters? Converts float to the smallest possible integer type ยท Optimizes memory usage when dealing with millions of rows ยท ๐Ÿ‘‰ Use this when memory efficiency matters. Using .round().astype(int) โ€“ When Rounding Matters ยท
๐ŸŒ
Statology
statology.org โ€บ home โ€บ how to convert numpy array of floats into integers
How to Convert NumPy Array of Floats into Integers
April 3, 2025 - Notice that each float has been rounded up to the nearest integer and the new array has a dtype of int64. The following code shows how to convert a NumPy array of floats to an array of integers using the np.floor() function, which rounds each value down to the nearest integer:
๐ŸŒ
Codegive
codegive.com โ€บ blog โ€บ pandas_float64_to_int.php
Master pandas float64 to int Conversion (2026 Guide): Seamlessly Transform Data & Unlock Insights
This tutorial will guide you through the intricacies of this process, providing robust methods, practical examples, and essential best practices to ensure your data types are always correct and optimized. Mastering this conversion will lead to cleaner data, reduced memory usage, and more reliable analyses. ... Robust Conversion with pd.to_numeric()4. Examples (multiple, practical, variations) ... Converting Multiple Columns5. Common Mistakes ... pandas float64 to int refers to the process of changing the data type of a Series or DataFrame column from float64 (a 64-bit floating-point number) to an integer type (like int64 or the nullable Int64).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-convert-integers-to-floats-in-pandas-dataframe
How to Convert Integers to Floats in Pandas DataFrame? | GeeksforGeeks
August 25, 2020 - Python3 ยท # Now we will convert it from 'int' to 'float' type # using DataFrame.astype() function df['Weight'] = df['Weight'].astype(float) print() # lets find out the data type after changing print(df.dtypes) # print dataframe. df ยท Output: In the above example, we change the data type of column 'Weight' from 'int64' to 'float64'.
๐ŸŒ
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 - The result is the integer part of each float. ๐Ÿ‘‰ Use this when you want a quick and simple way to convert floats to integers.
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-convert-float-to-int-in-python
How to convert float to int in Python - Altcademy.com
September 7, 2023 - In this code, round(x) rounds the float x to the nearest whole number (4 in this case), and then int() converts that rounded float to an integer. It's like if you're 3.99 steps up a staircase, rounding would say you're closer to the 4th step ...
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.to_numeric.html
pandas.to_numeric โ€” pandas 3.0.6 documentation - PyData |
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
๐ŸŒ
Python Examples
pythonexamples.org โ€บ python-convert-int-to-float
Convert Int to Float in Python - Examples
Implicit conversion is the process where Python interpreter converts the given int to float when the int is added/subtracted/etc., with a floating-point number.