use astype(np.int64)

s = pd.Series(['', 8.00735e+09, 4.35789e+09, 6.10644e+09])
mask = pd.to_numeric(s).notnull()
s.loc[mask] = s.loc[mask].astype(np.int64)
s

0              
1    8007350000
2    4357890000
3    6106440000
dtype: object
Answer from piRSquared on Stack Overflow
🌐
Saturn Cloud
saturncloud.io › blog › how-to-remove-decimal-points-in-pandas-a-guide-for-data-scientists
How to Remove Decimal Points in Pandas A Guide for Data Scientists | Saturn Cloud Blog
December 23, 2023 - The simplest way to remove decimal points in pandas is by using the round() function. This function rounds a given number to a specified number of decimal places. To remove all decimal points, you can set the number of decimal places to 0.
🌐
Reddit
reddit.com › r/learnpython › i have a pandas series, comprised entirely of string values, and i'm trying to remove trailing zeros and decimal points but it's dropping all zeroes at the end of the series values
r/learnpython on Reddit: I have a pandas series, comprised entirely of string values, and I'm trying to remove trailing zeros and decimal points but it's dropping all zeroes at the end of the series values
February 15, 2021 -

Here is the pandas series:

0           ? 
1          10 
2          15 
3          12 
4          90        
          ...  
79537     8.0 
79538    14.0 
79539    15.0 
79540    12.0 
79541    15.0
Name: Age, Length: 79542, dtype: object

I filled the NaN values in this series with '?' (hence the value at index 0) and all the values in this series are strings. I'm eventually going to make another column comprised of a base string added to the values in this series. Like this:

df['new column'] = 'age is: ' + df['Age']

this will make a new column with values like:

0          age is ? 
1          age is 10 
2          age is 15 
3          age is 12 
4          age is 90        
           ...  
79537      age is 8.0 
79538      age is 14.0 
79539      age is 15.0 
79540      age is 12.0 
79541      age is 15.0
Name: new column, Length: 79542, dtype: object

as for my project, i guess this is okay but it's bothering me that some of the values have a trailing zero. Again, everything here is a string.

I tried doing this:

df['new column'] = df['new column'].str.rstrip('0')

But it returns this:

0          age is ? 
1          age is 1 
2          age is 15 
3          age is 12 
4          age is 9        
           ...  
79537      age is 8. 
79538      age is 14. 
79539      age is 15. 
79540      age is 12. 
79541      age is 15.
Name: new column, Length: 79542, dtype: object

Note how the value at index 1 changed from 'age is 10' to 'age is 1', and the value at index 4 changed from 'age is 90' to 'age is 9'. This is would be fatal for my project. Also, the trailing decimal of the other values still bothers me.

I even tried this to get rid of the trailing decimal point:

df['new column'] = df['new column'].str.rstrip('.0')

But the problem isn't fully solved because indexes 1 and 4 are is still erroneous:

0          age is ? 
1          age is 1 
2          age is 15 
3          age is 12 
4          age is 9        
           ...  
79537      age is 8 
79538      age is 14 
79539      age is 15 
79540      age is 12 
79541      age is 15
Name: new column, Length: 79542, dtype: object

I presumably have many other values in this series that end in a zero (10, 20, 30, 40 etc) but I can't check manually because there are over 79k rows.

All i need is a way to drop trailing zeros after a decimal point, and also drop the decimal point itself, while also preserving values that are multiples of 10 and that do not have a trailing zero or decimal point. Basically, I need it to be like this:

0          age is ? 
1          age is 10 
2          age is 15 
3          age is 12 
4          age is 90        
           ...  
79537      age is 8 
79538      age is 14 
79539      age is 15 
79540      age is 12 
79541      age is 15
Name: new column, Length: 79542, dtype: object

Again, please note how the value at index 1 is 'age is 10' and not 'age is 1', and the value at index for is 'age is 90' and not 'age is 9'. Also, there are no decimal points or trailing zeros after a decimal point.

Any help would be appreciated. Thank you

🌐
Reddit
reddit.com › r/learnpython › how to terminate or remove the .0 point from an int.
r/learnpython on Reddit: How to terminate or remove the .0 point from an int.
December 9, 2022 -

Hello everyone,

I am still new to python and learning.

So I practiced some exercises and made an app that calculates the percentage from the number the user enters.

My question use, how can I terminate the .0 part if the user enters an Int and keep the decimal part if they enter a float?

so for example, 5% of 100 is 5 ( Int)

and 5.1% of 100 is 5.1 (float)

🌐
YouTube
youtube.com › watch
Pandas : Python - Remove decimal and zero from string
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Published   February 12, 2022
🌐
CodeProject
codeproject.com › Questions › 5291723 › How-do-I-remove-decimals-from-a-pandas-data-frame
How do I remove decimals from a pandas data frame index
September 1, 2021 - Do not try and find the page. That’s impossible. Instead only try to realise the truth - For those who code; Updated: 1 Jul 2007
🌐
Python Forum
python-forum.io › thread-29708.html
Dataframe Removes Zeros
September 16, 2020 - Hello all; I am importing an excel sheet into python as a dataframe using the code:- Report = pandas.read_excel(Crack_Report, sheet_name="Current", usecols=("A:BA"), skiprows=(4))In this excel sheet i
Find elsewhere
🌐
HatchJS
hatchjs.com › home › how to remove decimal points in pandas dataframe
How to Remove Decimal Points in Pandas DataFrame
January 5, 2024 - For example, to round the `”price”` column to two decimal places, you would use the following code: ... Use the `.dropna()` method. This method will drop any rows that contain missing values.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-remove-all-decimals-from-a-number-using-python
How to remove all decimals from a number using Python? - GeeksforGeeks
March 27, 2025 - In this article, let's see how to remove numbers from string in Pandas. Currently, we will be using only the .csv file for demonstration purposes, but the process is the same for other types of files. The function read_csv() is used to read CSV files.
🌐
AskPython
askpython.com › home › how to format floats without trailing zeros?
How to Format Floats Without Trailing Zeros? - AskPython
May 12, 2023 - The to_integral() function is used to check whether the given input number is blessed with a fractional portion or isn’t, whereas the normalize( ) function is used to remove the trailing zeros without any haze. One shall get things started by importing the decimal library as shown below.
🌐
Javatpoint
javatpoint.com › how-to-remove-decimal-in-python
How to Remove Decimal in Python - Javatpoint
How to Remove Decimal in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Stack Overflow
stackoverflow.com › questions › 70430412 › how-to-remove-decimal-and-zero-from-columns-of-a-dataframe-in-pandas-and-covert
python - How to remove decimal and zero from columns of a dataframe in pandas and covert it in string - Stack Overflow
reader = pd.read_csv( io.BytesIO(body), delimiter=",", quotechar='"', encoding="utf8", quoting=csv.QUOTE_ALL, skipinitialspace=True, usecols=cols, ) reader["columnA"] = reader["columnA"].astype(str).replace("\.0", "", regex=True)
🌐
GitHub
github.com › beepscore › pandas_decimal
GitHub - beepscore/pandas_decimal: Using Pandas with Python Decimal for accurate currency arithmetic · GitHub
CAUTION: c_float has 3 decimal places, removing its decimal multiplies by 1000, not 100. With integer arithmetic workaround, you need to keep all values consistent. To add a, b, c you could write a method to return an integer in tenths of cents. c_float = 0.125 c_int = int_by_removing_decimal(c_float) print(c_int) # 125
Author   beepscore
🌐
Stack Overflow
stackoverflow.com › questions › 67722165 › remove-decimal-in-pandas
python - Remove Decimal in pandas - Stack Overflow
You probably have a nan value in this column. You must remove them first, then convert to int: df["Time Period"].astype(int).
🌐
pythontutorials
pythontutorials.net › blog › how-to-remove-decimal-points-in-pandas
How to Remove Decimal Points in Pandas DataFrame: Convert Floats to Integers Successfully — pythontutorials.net
This blog will guide you through step-by-step methods to remove decimal points in a Pandas DataFrame, covering common scenarios like whole-number floats, floats with decimal parts, and columns with missing values (NaNs). We’ll also address pitfalls and best practices to ensure successful conversions. Understanding the Problem: Why Floats Have Decimals? ... Floats (floating-point numbers) in Pandas often retain decimal points even when they represent whole numbers (e.g., 5.0 ...