import pandas as pd
import datetime as dt
import random
base = pd.Timestamp.today()
timestamp_list = [base + dt.timedelta(minutes=x) for x in range(10)]
df = pd.DataFrame({'timestamp': [i for i in timestamp_list], 'col1': [random.randrange(1, 11) for i in range(10)]})
df = df.loc[(df['timestamp'].dt.minute % 5== 0).idxmax() :]
print (df)
2条答案
按热度按时间qoefvg9y1#
您可以转换为
DatetimeIndex
,然后提取分钟。最后应用模5,检查余数,并获得第一个True索引:输出:
py49o6xq2#
试试这个:
输出