subsetting a Python DataFrame

I’ll assume that Time and Product are columns in a DataFrame, df is an instance of DataFrame, and that other variables are scalar values: For now, you’ll have to reference the DataFrame instance: k1 = df.loc[(df.Product == p_id) & (df.Time >= start_time) & (df.Time < end_time), [‘Time’, ‘Product’]] The parentheses are also necessary, because of … Read more