Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
465 views
in Technique[技术] by (71.8m points)

timedelta - 类'datetime.time'不能转换为datetime(class 'datetime.time' is not convertible to datetime)

i tried x times different stuff from stackoverflow.

(我尝试了x倍于stackoverflow的东西。)

I have a dataframe with a duration column and datetime.time in this format 00:00:00.

(我有一个带有持续时间列和datetime.time的数据框,其格式为00:00:00。)

df['Duration'] = pd.to_datetime(df['Duration'])

(df ['Duration'] = pd.to_datetime(df ['Duration']))

shows me: is not convertible to datetime

(显示给我:不能转换为日期时间)

df['Duration'] =df['Duration'].apply(pd.Timestamp) shows me: Cannot convert input [02:17:20] of type to Timestamp

(df ['Duration'] = df ['Duration']。apply(pd.Timestamp)显示了我:无法将类型的输入[02:17:20]转换为Timestamp)

df["Duration"] = pd.to_timedelta(df["Duration"]) Invalid type for timedelta scalar:

(df [“ Duration”] = pd.to_timedelta(df [“ Duration”])timedelta标量的无效类型:)

I realy dont understand why this is so strange.

(我真的不明白为什么这是如此奇怪。)

The last to_timedelta has always worked for me.

(最后的to_timedelta一直为我工作。)

Please help

(请帮忙)

  ask by Eric Stralsund translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...