用两个条件列过滤数据框?
filter data frame with two conditions columns?
我有这样的数据集,
S.No. Counts No.rep Fram
1 3 4 UNC84A
2 10 4 UNC84A
3 7 4 UNC84A
4 10.3 4 UNC84A
5 7 1 NTUD19
6 181 3 ALR6IP4
7 7 3 ALR6IP4
8 21 3 ALR6IP4
我想过滤 "if No.rep>=3",然后过滤 select 列,其中有 "Counts>= 10"。此外,当 No.rep < 3 时,我还需要具有计数 < 10 的列。
这是我需要的输出
S.No. Counts No.rep Fram
2 10 4 UNC84A
4 10.3 4 UNC84A
5 7 1 NTUD19
6 181 3 ALR6IP4
8 21 3 ALR6IP4
你可以试试:
df[df["No.rep"] >= 3 & df["Counts"] >= 10,]
S.No. Counts No.rep Fram
2 10.0 4 UNC84A
4 10.3 4 UNC84A
6 181.0 3 ALR6IP4
8 21.0 3 ALR6IP4
编辑:
你想要这样的 OR 条件吗:
df[(df["No.rep"] >= 3 & df["Counts"] >= 10) | (df["No.rep"] < 3 & df["Counts"] < 10),]
S.No. Counts No.rep Fram
2 10.0 4 UNC84A
4 10.3 4 UNC84A
5 7.0 1 NTUD19
6 181.0 3 ALR6IP4
8 21.0 3 ALR6IP4
我有这样的数据集,
S.No. Counts No.rep Fram
1 3 4 UNC84A
2 10 4 UNC84A
3 7 4 UNC84A
4 10.3 4 UNC84A
5 7 1 NTUD19
6 181 3 ALR6IP4
7 7 3 ALR6IP4
8 21 3 ALR6IP4
我想过滤 "if No.rep>=3",然后过滤 select 列,其中有 "Counts>= 10"。此外,当 No.rep < 3 时,我还需要具有计数 < 10 的列。
这是我需要的输出
S.No. Counts No.rep Fram
2 10 4 UNC84A
4 10.3 4 UNC84A
5 7 1 NTUD19
6 181 3 ALR6IP4
8 21 3 ALR6IP4
你可以试试:
df[df["No.rep"] >= 3 & df["Counts"] >= 10,]
S.No. Counts No.rep Fram
2 10.0 4 UNC84A
4 10.3 4 UNC84A
6 181.0 3 ALR6IP4
8 21.0 3 ALR6IP4
编辑:
你想要这样的 OR 条件吗:
df[(df["No.rep"] >= 3 & df["Counts"] >= 10) | (df["No.rep"] < 3 & df["Counts"] < 10),]
S.No. Counts No.rep Fram
2 10.0 4 UNC84A
4 10.3 4 UNC84A
5 7.0 1 NTUD19
6 181.0 3 ALR6IP4
8 21.0 3 ALR6IP4