我有一个pandas数据框,该数据框由一些非唯一非连续的ID编号索引。
X
class'pandas.core.frame.DataFrame'
Int64Index:814061条目,8536896至8498857
数据列(共1列):
收到814061个非空值
dtypes:datetime64ns
x ['received']是不一样长度的时间戳。
x.ix[i] might have len() == 20
x.ix[j] might have len() == 32.
对于任何x.ix [i]我可以将时间戳放入[0,1]范围
df['totalseconds'] = x.ix[i]['received']-x.ix[i]['received'].min()
y = x.ix[i]['received'].max()-x.ix[i]['received'].min()
z = timedelta.total_seconds(y)
df['seconds'] = df['totalseconds'].apply(lambda x: x / timedelta64(1, 's'))
df['norm'] = df['seconds']/z
我正在尝试将x中每个索引的时间段规范化。但由于某种原因我遇到了麻烦。
tldr;如何通过索引ID将所有时间戳记放入[0,1]范围?