Search code examples
pythonpandasscikit-learngoogle-colaboratory

too many zeros in my google colaboratory after using imputer and column transformer


Sorry, I am new in Data science. so I have dataset like this (full code below)

enter image description here

and then I want to fill the missing data

enter image description here

as you can see, there is a lot zeros (44.0000000), can I make it just (44.0) ?

category = ["Age","Salary"]
imputer_strategy = SimpleImputer(strategy="mean")

imputer = ColumnTransformer([
    ("cat",imputer_strategy,category)
])

X.iloc[:,1:] = imputer.fit_transform(X.iloc[:,1:])
X

Solution

  • You can add this line in your code to get the format you need:

    pd.options.display.float_format = '{:,.1f}'.format