1

I am reading an excel file using pandas function read_excel() function but pandas auto removed the .00 values from the data of dataframe.

Sample excel sheet Structure

Name    iteam   Price   Amount
qwe        2    20      40
dfg        1    23.00   34.01
rfe        0    0.00    0.00

Reading Above excel using below pandas function

import pandas as pd
df=pd.read_excel(path,sheet_name="<Sheet_name>",header=None,dtype=object)

Reading every data as an object as that missing values will not affect datatype of dataframe. DataFrame Created after executing the above line

index   Name    iteam   Price   Amount
  0      qwe      2       20    40
  1      dfg      1       23    34.01
  2      rfe      0        0    0

dataframe convert (0.00 to 0)and (23.00 to 23). Is there any way to restrict pandas from such conversions in dataframe?

Desired Dataframe structure

index   Name    iteam   Price   Amount
  0      qwe      2       20     40
  1      dfg      1       23.00  34.01
  2      rfe      0       0.00   0.00
Naruto
  • 139
  • 1
  • 10

0 Answers0