@@ -1003,13 +1003,25 @@ def __getitem__(self, rows):
10031003 else :
10041004 return self .table ._get_row_indices (rows )
10051005
1006- def match (self , regexp ,col = None ):
1006+ def match (self , regexp = None ,col = None , ** kwargs ):
10071007 """Get indices of rows matching the regular expression on the column (default is index)."""
1008+ if regexp is None :
1009+ if len (kwargs ) == 0 :
1010+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1011+ if len (kwargs ) > 1 :
1012+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1013+ col , regexp = list (kwargs .items ())[0 ]
10081014 col = self .table ._index if col is None else col
10091015 return self .table ._get_col_regexp_indices (regexp , col )
10101016
1011- def match_not (self , regexp ,col = None ):
1017+ def match_not (self , regexp ,col = None , ** kwargs ):
10121018 """Get indices of rows not matching the regular expression on the column (default is index)."""
1019+ if regexp is None :
1020+ if len (kwargs ) == 0 :
1021+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1022+ if len (kwargs ) > 1 :
1023+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1024+ col , regexp = list (kwargs .items ())[0 ]
10131025 col = self .table ._index if col is None else col
10141026 indices = self .table ._get_col_regexp_indices (regexp , col )
10151027 return np .setdiff1d (np .arange (len (self .table )), indices )
@@ -1025,14 +1037,26 @@ def __getitem__(self, rows):
10251037 mask [indices ] = True
10261038 return mask
10271039
1028- def match (self , regexp ,col = None ):
1040+ def match (self , regexp = None ,col = None , ** kwargs ):
10291041 """Get mask of rows matching the regular expression on the column (default is index)."""
1042+ if regexp is None :
1043+ if len (kwargs ) == 0 :
1044+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1045+ if len (kwargs ) > 1 :
1046+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1047+ col , regexp = list (kwargs .items ())[0 ]
10301048 col = self .table ._index if col is None else col
10311049 indices = self .table ._get_col_regexp_indices (regexp , col )
10321050 return self .table .rows .mask [indices ]
10331051
1034- def match_not (self , regexp ,col = None ):
1052+ def match_not (self , regexp = None ,col = None , ** kwargs ):
10351053 """Get mask of rows not matching the regular expression on the column (default is index)."""
1054+ if regexp is None :
1055+ if len (kwargs ) == 0 :
1056+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1057+ if len (kwargs ) > 1 :
1058+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1059+ col , regexp = list (kwargs .items ())[0 ]
10361060 col = self .table ._index if col is None else col
10371061 indices = self .table ._get_col_regexp_indices (regexp , col )
10381062 full_mask = np .ones (len (self .table ), dtype = bool )
@@ -1121,14 +1145,26 @@ def get_col_regexp_indices(self, regexp, col):
11211145 print ("Deprecated: use table.rows.match instead of get_col_regexp_indices" )
11221146 return self .table ._get_col_regexp_indices (regexp , col )
11231147
1124- def match (self , regexp ,col = None ):
1148+ def match (self , regexp = None ,col = None , ** kwargs ):
11251149 """Get a mask of rows matching the regular expression on the column (default is index)."""
1150+ if regexp is None :
1151+ if len (kwargs ) == 0 :
1152+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1153+ if len (kwargs ) > 1 :
1154+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1155+ col , regexp = list (kwargs .items ())[0 ]
11261156 col = self .table ._index if col is None else col
11271157 indices = self .table ._get_col_regexp_indices (regexp , col )
11281158 return self .table ._select_rows (indices )
11291159
1130- def match_not (self , regexp ,col = None ):
1160+ def match_not (self , regexp = None ,col = None , ** kwargs ):
11311161 """Get a mask of rows not matching the regular expression on the column (default is index)."""
1162+ if regexp is None :
1163+ if len (kwargs ) == 0 :
1164+ raise ValueError ("Either regexp or keyword arguments must be provided." )
1165+ if len (kwargs ) > 1 :
1166+ raise ValueError ("Only one keyword argument is allowed and it must be a column name." )
1167+ col , regexp = list (kwargs .items ())[0 ]
11321168 col = self .table ._index if col is None else col
11331169 indices = self .table ._get_col_regexp_indices (regexp , col )
11341170 indices = np .setdiff1d (np .arange (len (self .table )), indices )
0 commit comments