简体   繁体   English

Dataframe 具有不同格式的日期值的字符串列。 如何将整列数据转换为单个日期格式?

[英]Dataframe has string column with date values in different formats. how to convert entire column data to single date format?

converting string to datetime in python pandas with multiple date formats in a column.将 python pandas 中的字符串转换为日期时间,列中具有多种日期格式。

Dataframe startdate has date values in 'mm-dd-YYYY hh:mm' format and 'mm/dd/YYYY hh:mm' format. Dataframe startdate 具有“mm-dd-YYYY hh:mm”格式和“mm/dd/YYYY hh:mm”格式的日期值。 I have used following query我使用了以下查询

  df['START_DATE*'] = pd.to_datetime(df['START_DATE*'], format= '%m-%d-%Y hh:mm')

START_DATE* is the column name.giving following START_DATE* 是列名。给出以下内容

time data '01-01-2016 21:11' does not match format '%m-%d-%Y hh:mm' (match)时间数据 '01-01-2016 21:11' 与格式 '%m-%d-%Y hh:mm' 不匹配(匹配)

hh:mm does not mean hour:minute . hh:mm并不意味着hour:minute Try:尝试:

df['START_DATE*'] = pd.to_datetime(df['START_DATE*'], format= '%m-%d-%Y %H:%M')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将不同的日期格式转换为数据框列中的单一格式 - Converting different date formats to a single format in a dataframe column 如何将 PySpark/Pandas 数据框中的日期/自定义/通用格式的列值转换为日期格式? - How to convert column values present in date/custom/general formats in a PySpark/Pandas dataframe into a Date Format? 如何在具有不同日期格式的列上将字符串转换为日期 - How to convert string to date on a column with different date formats 如何将 pandas dataframe 列中的两种不同日期格式转换为相同格式? - How to convert two different date formats from a pandas dataframe column into same format? 将日期转换为整个新列的不同格式 - Convert a date to a different format for an entire new column 当列中已存在多种日期格式时,更改整个 Dataframe 列的日期格式? - Changing the date format of an entire Dataframe column when multiple date formats already exist in the column? 需要将整个列从字符串格式转换为数据帧中的日期格式 - Need to convert entire column from string format to date format from a Dataframe 如何为python数据框中的整个列创建日期格式? - How do I make a date format for an entire column in python dataframe? 将字符串列直接转换为 Pandas DataFrame 中的日期格式(不是日期时间) - Convert String Column directly to Date format (not Datetime) in Pandas DataFrame 将时间戳从 dataframe 列转换为日期格式 - Convert timestamps from a dataframe column to date format
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM