0
我有对象类型的这样的柱:如何将对象类型转换为python jupyter中的datetime64 [ns]?
quote['SellTime'].head()
Out[32]:
0 94520
1 94538
2 94609
3 94615
4 94617
Name: SellTime, dtype: object
我想将其转换为对日期时间(datetime64 [NS])格式。
我也做了下面的代码:
quote['SellTime'].astype(str).astype(int)
t2 = quote['SellTime'].astype(str).str.zfill(6)
quote['SellTime'] = pd.to_datetime(t2, format='%H%M%S').dt.time
,但它仍然是对象类型:
quote['SellTime'].head()
0 09:45:20
1 09:45:38
2 09:46:09
3 09:46:15
4 09:46:17
Name: SellTime, dtype: object
我都试过,但我不不想在SellTime开始只是需要时间不是一年 – ary
我想我明白那年,但不可能在python中创建没有日期的日期。但是可以创建[timedelta](http://pandas.pydata.org/pandas-docs/stable/timedeltas.html),whot是最接近你需要的。 – jezrael
That worked Tnx – ary