0

I would like to apply mutiply keyword filter for filtering down on columns.I tried this code:

df = df.filter(regex='AMP','amp','date') 

Error I get :

df = df.filter(regex='AMP','amp','date')
                                ^
SyntaxError: positional argument follows keyword argument.

Basically,I want all the columns with these keywords contained in their column name. Thank you in advance

Vikas Periyadath
  • 3,088
  • 1
  • 21
  • 33
Unknown
  • 77
  • 3
  • 12
  • error message says: never use positional erguments behind keyword arguments in python - simply because position is meaningless after an arbitrary list of kwargs is provided – SpghttCd May 11 '18 at 07:11
  • basically `df = df.filter('AMP','amp','date')` – aelor May 11 '18 at 07:14

1 Answers1

3

The regex has to be one valid regex string. You separated three strings by comma, so python interpreted the last two strings as separate arguments (without keyword). the proper 'or' - operator in regex is '|', so your desired filter would look like this:

df.filter(regex='AMP|amp|date')
SpghttCd
  • 10,510
  • 2
  • 20
  • 25