pandas处理日期时报错 AttributeError: Can only use .str accessor with string values!

原因excel的日期格式,用pandas读入时也是时间格式,而pandas中模糊匹配函数(.str.contain)需要字符串类型。需要进行转换

data['时间'] = data['时间'].apply(lambda x:x.strftime('%Y-%m-%d'))

pandas处理日期时报错 AttributeError: Can only use .str accessor with string values!_第1张图片

 

你可能感兴趣的:(pandas,python,数据分析)