python read_excel converters,使用python中的大熊猫的read_excel函数将日期作为字符串

在Python中使用pandas的read_excel函数时,日期列会自动转换为datetime类型。文章探讨了如何避免这种自动转换,尝试了不同的方法,包括设置parse_dates参数和使用lambda函数,但未能阻止转换。最后,提出了使用converters参数,如`pandas.read_excel(xlsx, sheet, converters={'Date': str})`来保持日期列为字符串格式。" 112037827,10553794,移动端Vue+Vant图片上传压缩旋转教程,"['前端开发', 'Vue', 'Vant', '图片处理', 'canvas']
摘要由CSDN通过智能技术生成

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()

When using pandas in Python is it possible to read excel files (formats: xls|xlsx) and leave columns containing date or date + time values as strings rather than auto-converting to datetime.datetime or timestamp types?

If this is not possible using pandas can someone suggest an alternate method/library to read xls|xlsx files and leave date column values as strings?

For the pandas solution attempts the df.info() and resultant date column types are shown below:

>>> df.info()

Int64Index: 117 entries, 0 to 116

Columns: 176 entries, Mine to Index

dtypes: datetime64[ns](2), float64(145), int64(26), object(3)

memory usage: 161.8+ KB

>>> type(df['Start Date'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值