Python 2.7.10
Tried pandas 0.17.1 -- function read_excel
Tried pyexcel 0.1.7 + pyexcel-xlsx 0.0.7 -- function get_records()
I tried saving the file in a CSV UTF-8 format
(manually) and used pd.read_csv()
and worked fine.
I tried a bunch of things to figure the same thing with read_excel
. Did not work anything for me. So, I am guessing read_excel
is probably updating your string in a datetime object which you can not control.
pandas.read_excel(xlsx, sheet, converters={'Date': str})
df['Date'][0].strftime('%Y/%m/%d')
I ran into an identical problem, except pandas was oddly converting only some cells into datetimes. I ended up manually converting each cell into a string like so:
def undate(x):
if pd.isnull(x):
return x
try:
return x.strftime('%d/%m/%Y')
except AttributeError:
return x
except Exception:
raise
for i in list_of_possible_date_columns:
df[i] = df[i].apply(undate)