我不知道如何从pandas列中提取时间戳。
使用以下代码,我将获得以下信息。
print("Nested ----------------------------")
print(type(nested_full['data.tick_timestamp']))
ts2 = nested_full['data.tick_timestamp']
print("type of timestamp")
print(ts2)
diff_seconds = util.seconds_since_mightnight(ts2) # Fail here because of invalid data??
Nested ----------------------------
<class 'pandas.core.series.Series'>
type of timestamp
0 1574417975007
Name: data.tick_timestamp, dtype: int64
答案 0 :(得分:0)
我认为您需要一个元素Series
的标量,因此请使用Series.iat
并选择第一个值:
out = nested_full['data.tick_timestamp'].iat[0]
out = nested_full['data.tick_timestamp'].iloc[0]
如果想要日期时间的numpy repr:
out = nested_full['data.tick_timestamp'].values[0]
#pandas 0.24+
out = nested_full['data.tick_timestamp'].to_numpy()[0]