我有这种形式的DataFrame:
time_stamp src_ip dst_ip
...
...
2430355 2019-05-28 23:19:25 10.0.0.125 34.236.210.83
2430356 2019-05-28 23:19:25 10.0.3.58 104.24.0.13
2430357 2019-05-28 23:19:25 10.0.0.100 23.200.101.62
2430358 2019-05-28 23:19:25 10.1.3.2 172.224.12.136
2430359 2019-05-28 23:19:25 10.1.0.234 104.16.48.55
...
...
并且我试图在该DataFrame的子集中获取与特定条件匹配的行:
data.iloc[67048:67058][data.iloc[67048:67058]['dst_ip'] == '159.45.170.143']
(子集为 [67048:67058] ,条件为 ['dst_ip'] == '159.45.170.143'] )
这很好,但感觉很麻烦。有没有更好的方法来执行此查询?
答案 0 :(得分:2)
更新
data.iloc[67048:67058].query("dst_ip == '159.45.170.143'")