Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: convert excel data into dataframes

I want to put some data available in an excel file into a dataframe in Python. The code I use is as below (two examples I use to read an excel file):

d=pd.ExcelFile(fileName).parse('CT_lot4_LDO_3Tbin1')
e=pandas.read_excel(fileName, sheetname='CT_lot4_LDO_3Tbin1',convert_float=True)

The problem is that the dataframe I get has the values with only two numbers after comma. In other words, excel values are like 0.123456 and I get into the dataframe values like 0.12.

A round up or something like that seems to be done, but I cannot find how to change it.

Can anyone help me?

thanks for the help !

like image 764
Guillaume Avatar asked Oct 17 '25 16:10

Guillaume


1 Answers

You can try this. I used test.xlsx which has two sheets, and 'CT_lot4_LDO_3Tbin1' is the second sheet. I also set the first value as Text format in excel.

import pandas as pd 
fileName = 'test.xlsx'
df = pd.read_excel(fileName,sheetname='CT_lot4_LDO_3Tbin1')

Result:

In [9]: df
Out[9]: 
       Test
0  0.123456
1  0.123456
2  0.132320

Without seeing the real raw data file, I think this is the best answer I can think of.

like image 79
Chih-Hsu Jack Lin Avatar answered Oct 19 '25 06:10

Chih-Hsu Jack Lin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!