擅长:python、mysql、java
<p>试试这个:</p>
<pre><code>ts_failure = datetime.datetime(2019, 5, 15, 19, 48, 2, 495)
nearest_idx = np.searchsorted(df['Timestamp'], ts_failure) - 1
nearest_time = df.iloc[nearest_idx]['Timestamp']
t_500ms = nearest_time - pd.Timedelta(milliseconds = 500)
df.index = df['Timestamp']
df2 = df.loc[t_500ms: nearest_time]
</code></pre>