小编Kia*_*ann的帖子

过滤熊猫行,其中列中的第一个字母是/不是某个值

如何过滤掉我不希望第一个字母为“Z”或任何其他字符的一系列数据(在 Pandas dataFrame 中)。

我有以下熊猫数据帧,df,(其中有 > 25,000 行)。

TIME_STAMP  Activity    Action  Quantity    EPIC    Price   Sub-activity    Venue
0   2017-08-30 08:00:05.000 Allocation  BUY 50  RRS 77.6    CPTY    066
1   2017-08-30 08:00:05.000 Allocation  BUY 50  RRS 77.6    CPTY    066
3   2017-08-30 08:00:09.000 Allocation  BUY 91  BATS    47.875  CPTY    PXINLN
4   2017-08-30 08:00:10.000 Allocation  BUY 43  PNN 8.07    CPTY    WCAPD
5   2017-08-30 08:00:10.000 Allocation  BUY 270 SGE 6.93    CPTY    PROBDMAD
Run Code Online (Sandbox Code Playgroud)

我正在尝试删除 Venue 的第一个字母为“Z”的所有行。

例如,我通常的过滤器代码类似于(过滤掉 Venue = '066' 的所有行

df = df[df.Venue != '066']
Run Code Online (Sandbox Code Playgroud)

我可以看到这个过滤器行过滤掉了我需要的数组,但我不确定如何在过滤器上下文中指定它。 …

python filter dataframe python-3.x pandas

5
推荐指数
1
解决办法
9855
查看次数

标签 统计

dataframe ×1

filter ×1

pandas ×1

python ×1

python-3.x ×1