Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Float formatting
#1
import pandas as pd
import numpy as np
df3 = pd.DataFrame({
'T': [11.0,22.0,11.23,20.03],
'v2': [11.0,13.0,55.1,33.0],
'v3' : [112.1,2.0,2.1,366.0],
'v4': [np.nan, "blue", 1.0, 2.0]
 })

df3['T'] = np.nan_to_num(df3['T']).astype(int)

print(df3['T'])
output is
0 11
1 22
2 11
3 20
Name: T, dtype: int32


The column T has values 11.0 ,22.0 ,11.23,20.03 the output should be like 11,22,11.23,20.03

how to remove the zeros and retain the other values after decimal(.)
Reply


Messages In This Thread
Float formatting - by ambush - Dec-13-2018, 12:30 PM
RE: Float formatting - by Axel_Erfurt - Dec-13-2018, 03:06 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020