I have a .xls
file that looks like this
col_a col_b col_c col_d
5376594 hello
12028432 world
17735732 hello 12 hello
17736843 world world
when I read the file with
test = pandas.read_excel('F:/test.xls')
The table is read with the following column types:
>>> test.dtypes
col_a int64
col_b object
col_c float64
col_d object
The problem I have is that I would like to have string columns for col_b
and col_d
. Since I'm quite new at python, can you please point me to
- what is happening behind the scenes? and
- Is there any parameter to adjust to read the column as string?
EDIT: Types for the first row as asked in comment
>>> type(test.iloc[0]['col_a'])
<class 'numpy.int64'>
>>> type(test.iloc[0]['col_b'])
<class 'float'>
>>> type(test.iloc[0]['col_c'])
<class 'numpy.float64'>
>>> type(test.iloc[0]['col_d'])
<class 'str'>