按条件从dataframe中筛选符合条件的行

例子1:精确指定条件

df_mots[(df_mots['time'] < 25320)&(df_mots['time'] >= 25270)]

例子2:模糊条件,包含指定字符串(包含变量)

    df = df[df['director'].notnull()]   # 筛选非空数据

.str.contains方法
df_new = df_mots[(df_mots["HOUR_ID"] == hour_list[b]) & (df_mots['BSC_TS'].str.contains(Moid))]
原文地址:https://www.cnblogs.com/huangyz-xy/p/12900884.html