Python / Pandas:使用Regex过滤行

时间:2017-03-02 20:11:42

标签: python regex string pandas filter

我试图通过排除Amount包含的任何行来过滤此DataFrame?或 - 符号如下所示:

  table = table[~table['Amount'].str.contains('-|?', na=False)]

   Date        Description                               Amount   AutoNumber
0  3/17/2015        WW120 TFR?FR xxx8690                 $140.00     49246
1  3/16/2015        PHO HOAN PASTEU                     ?$27.83?     49246
2  3/16/2015        Millennium Card FEE                 ?$44.00?     49246
3  3/16/2015        SSV TO: xxxxxxx8690                 ?$3.00?      49246
4  3/16/2015        HUSKY RIVERVIEW                     ?$15.97?     49246
0  03/16/2015       Payroll DepositDOLLARSDIRECT         $200.00     49248
1  03/14/2015       POS PurchaseFPOS LEO'S ESSO LONDO    $-3.59      49248
2  03/14/2015       ABM Withdrawal                       $-103.00    49248
3  03/14/2015       Service Charge                       $-1.50      49248
4  03/13/2015       LoansLibro Credit Union              $155.84     49248

我正在寻找的输出是:

   Date        Description                               Amount   AutoNumber
0  3/17/2015        WW120 TFR?FR xxx8690                 $140.00     49246
0  03/16/2015       Payroll DepositDOLLARSDIRECT         $200.00     49248
4  03/13/2015       LoansLibro Credit Union              $155.84     49248

但是,我收到以下错误:

  File "C:\Python27\lib\re.py", line 251, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat

0 个答案:

没有答案