May-05-2022, 10:12 PM
(This post was last modified: May-05-2022, 10:12 PM by deanhystad.)
You can make a new dataframe that only contains the values you want. Here I "delete" all values >= 50 and save the results in "low". You could do the same thing by comparing datetime objects.
import pandas as pd import numpy as np df = pd.DataFrame({"Letters":[a for a in 'ABCDEFG'], "Numbers":np.random.randint(1, 100, 7)}) low = df[df["Numbers"] < 50] high = df[df["Numbers"] >= 50] print("Low", low, sep="\n") print("\nHigh", high, sep="\n")
Output:Low
Letters Numbers
1 B 26
2 C 8
High
Letters Numbers
0 A 74
3 D 56
4 E 74
5 F 56
6 G 51