Issue
I have an Excel file. One of the columns is type General
. Values in this column have formats like 10cm
, 0
, 1
, TRUE
and FALSE
. Now I'm using Pandas to parse the Excel file into a dataframe and then save them in a table in SQLite. I want the values in this column keep its own format.
I have used xl=pd.ExcelFile()
to read the file and xl.parse()
to read the data. But the FALSE
value in the column become 0
, which confuses me with real 0
value. The code line is
df=xl.parse(sheet_name=sheet,names=columns,skiprows=2)
where the sheet is a given sheetname and columns is a list of column names.
Could someone help me with the issue?
Solution
This is how I got it-
df = pd.read_excel('C:\\Users\\Downloads\\Practice\\Book1.xlsx',header=0,converters={'General':str})
df
Output
General 10cm 0 1 True False
Answered By - JaySean
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.