You can try by doing df["Bare Nuclei"].astype(np.int64) but as far as I can see the problem is something else. Pandas first reads all the data to best estimate the data type for each column, then only makes the data frame. So, there must be some entries in the data frame which are not integer types, i.e., they may contain some letters. In that case, also typecasting should give an error. So you need to remove those entries before successfully making the table integer.

Answer from Rabin Adhikari on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.astype.html
pandas.DataFrame.astype — pandas 3.0.3 documentation
Changed in version 2.0.0: Using astype to convert from timezone-naive dtype to timezone-aware dtype will raise an exception. Use Series.dt.tz_localize() instead. ... >>> d = {"col1": [1, 2], "col2": [3, 4]} >>> df = pd.DataFrame(data=d) >>> df.dtypes col1 int64 col2 int64 dtype: object ... >>> ser = pd.Series([1, 2], dtype="int32") >>> ser 0 1 1 2 dtype: int32 >>> ser.astype("int64") 0 1 1 2 dtype: int64 ... >>> from pandas.api.types import CategoricalDtype >>> cat_dtype = CategoricalDtype(categories=[2, 1], ordered=True) >>> ser.astype(cat_dtype) 0 1 1 2 dtype: category Categories (2, int64): [2 < 1]
🌐
Statology
statology.org › home › pandas: how to convert object to int
Pandas: How to Convert object to int
July 16, 2022 - This tutorial explains how to convert a column in a pandas DataFrame from an object to an integer, including examples.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.3 documentation
>>> s = pd.Series([1, 2, 3], dtype="Int64") >>> pd.to_numeric(s, downcast="integer") 0 1 1 2 2 3 dtype: Int8 >>> s = pd.Series([1.0, 2.1, 3.0], dtype="Float64") >>> pd.to_numeric(s, downcast="float") 0 1.0 1 2.1 2 3.0 dtype: Float32
🌐
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 - To transform a Pandas column to an integer type within a DataFrame, you have the option to utilize either the DataFrame's astype(int) or the apply() method. This enables the conversion of a column from various data types such as float or string ...
🌐
Sentry
sentry.io › sentry answers › python › change a column type in a dataframe in python pandas
Change a column type in a DataFrame in Python Pandas | Sentry
A B C 0 1 4 7 1 2 5 8 2 3 6 9 A object B object C object dtype: object Converted: A B C 0 1.0 4 7 1 2.0 5 8 2 3.0 6 9 A float64 B int64 C int64 dtype: object · If we want to convert a column to a numeric type, we can use the to_numeric function.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.convert_dtypes.html
pandas.DataFrame.convert_dtypes — pandas 3.0.3 documentation
>>> df.dtypes a int32 b object c object d object e float64 f float64 dtype: object · Convert the DataFrame to use best possible dtypes. >>> dfn = df.convert_dtypes() >>> dfn a b c d e f 0 1 x True h 10 <NA> 1 2 y False i <NA> 100.5 2 3 z <NA> <NA> 20 200.0 · >>> dfn.dtypes a Int32 b string c boolean d string e Int64 f Float64 dtype: object ·
🌐
Quora
quora.com › How-do-I-change-an-object-to-int-in-Pandas
How to change an object to int in Pandas - Quora
Answer: I would consider this more a Python question than a pandas question. All objects have a type, and int or integer is one of those types. 0, -3, 1, 9 are all int type literals, whereas “0” is a string (and not even a legal Python string, as if you look closely, the quote-marks are ...
Find elsewhere
🌐
GitHub
github.com › pandas-dev › pandas › issues › 28599
Series of object/strings cannot be converted to Int64Dtype() · Issue #28599 · pandas-dev/pandas
September 24, 2019 - --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-2-5778d49bfa2e> in <module>() 2 a = pd.Series(['123', '345', '456']) 3 print(a.astype(int)) ----> 4 print(a.astype('Int64')) /home/sestovic/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in astype(self, dtype, copy, errors, **kwargs) 5880 # else, only a single dtype is given 5881 new_data = self._data.astype( -> 5882 dtype=dtype, copy=copy, errors=errors, **kwargs 5883 ) 5884 return self._constructor(new_data).__finalize__(self) /home/sestovic/ana
Author   pandas-dev
🌐
YouTube
youtube.com › watch
Convert datatypes using Python Pandas - Float and String to integer - YouTube
Code:import pandas as pddf=pd.read_csv('C:/temp/convert.txt',sep=';')print(df.dtypes)df['Decimals']=df['Decimals'].astype(int)df['Comma']=df['Comma'].str.rep...
Published   April 17, 2020
🌐
Python for Data Science
python4data.science › en › latest › workspace › pandas › convert-dtypes.html
Convert dtype - Python for Data Science
1 month ago - The usual data type is 8 bytes wide, for example int64 or float64. If you can use a narrower type, this will significantly reduce memory consumption, allowing you to process more data. You can use NumPy to check the limits of integer and float types: ... To calculate the memory consumption of the Series, you can use pandas.Series.nbytes to determine the memory used by the data.
🌐
CopyProgramming
copyprogramming.com › howto › converting-object-to-int-pandas
Python: Transforming Pandas Object into Integer
May 16, 2023 - Converting a Pandas String Column to the New Nullable Int64 Type · DataFrame values of integers are converted to floats by Pandas · Using Float32 for All Float Columns in pandas read_csv · Downcasting Integer with Python's Pandas to Numeric Series · Transforming Pandas Data Frame Object Class to Numeric Class ·
🌐
datagy
datagy.io › home › pandas tutorials › data analysis in pandas › converting pandas dataframe column from object to float
Converting Pandas DataFrame Column from Object to Float • datagy
May 12, 2023 - One of the most common ways to convert a Pandas DataFrame column’s data type from object to float is to use the Pandas astype method. The astype method allows you to pass in a data type that you want to use.
🌐
Skytowner
skytowner.com › explore › converting_column_type_to_integer_in_pandas_dataframe
Converting column type to integer in Pandas DataFrame
Pandas to_numeric(~) method converts the input to a numerical type. By default, either int64 or float64 will be used.
🌐
Data Carpentry
datacarpentry.github.io › python-ecology-lesson › 04-data-types-and-format
Data Analysis and Visualization in Python for Ecologists: Data Types and Formats
June 5, 2023 - A type ‘O’ just stands for “object” which in pandas is a string (text). ... The type int64 tells us that pandas is storing each value within this column as a 64 bit integer.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › different ways to change data type in pandas
Different Ways to Change Data Type in Pandas - Spark By {Examples} %
March 27, 2024 - Post category:Pandas · Post last modified:March 27, 2024 · Reading time:17 mins read · You must be a Monthly member to access this content. Join Now · Already a member? Log in here · Tags: DataFrame.astype(), DataFrame.convert_dttypes(), DataFrame.infer_objects(), DataFrame.to_numeric() Log In
🌐
Linux Hint
linuxhint.com › pandas-convert-column-int
Pandas Convert Column to Int
August 17, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Towards Data Science
towardsdatascience.com › 6-pandas-tricks-you-should-know-to-speed-up-your-data-analysis-d3dec7c29e5
6 Pandas tricks you should know to speed up your data analysis | by Robin Chan | Towards Data Science
December 15, 2021 - In this article, you’ll learn some of the most helpful Pandas tricks to speed up your data analysis. ... Please check out my Github repo for the source code. ... df.dtypesPassengerId int64 Survived int64 Pclass int64 Name object Sex object Age float64 SibSp int64 Parch int64 Ticket object Fare float64 Cabin object Embarked object dtype: object