Skip to content

Commit 095b13f

Browse files
jbrockmendeljreback
authored andcommitted
CLN: explicit kwargs and docstring for create_index (#29971)
1 parent e341df2 commit 095b13f

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

pandas/io/pytables.py

+33-7
Original file line numberDiff line numberDiff line change
@@ -1191,13 +1191,31 @@ def append_to_multiple(
11911191

11921192
self.append(k, val, data_columns=dc, **kwargs)
11931193

1194-
def create_table_index(self, key: str, **kwargs):
1194+
def create_table_index(
1195+
self,
1196+
key: str,
1197+
columns=None,
1198+
optlevel: Optional[int] = None,
1199+
kind: Optional[str] = None,
1200+
):
11951201
"""
11961202
Create a pytables index on the table.
11971203
11981204
Parameters
11991205
----------
12001206
key : str
1207+
columns : None, bool, or listlike[str]
1208+
Indicate which columns to create an index on.
1209+
1210+
* False : Do not create any indexes.
1211+
* True : Create indexes on all columns.
1212+
* None : Create indexes on all columns.
1213+
* listlike : Create indexes on the given columns.
1214+
1215+
optlevel : int or None, default None
1216+
Optimization level, if None, pytables defaults to 6.
1217+
kind : str or None, default None
1218+
Kind of index, if None, pytables defaults to "medium"
12011219
12021220
Raises
12031221
------
@@ -1212,7 +1230,7 @@ def create_table_index(self, key: str, **kwargs):
12121230

12131231
if not isinstance(s, Table):
12141232
raise TypeError("cannot create table index on a Fixed format store")
1215-
s.create_index(**kwargs)
1233+
s.create_index(columns=columns, optlevel=optlevel, kind=kind)
12161234

12171235
def groups(self):
12181236
"""
@@ -3519,18 +3537,26 @@ def f(i, c):
35193537

35203538
return self._indexables
35213539

3522-
def create_index(self, columns=None, optlevel=None, kind=None):
3540+
def create_index(self, columns=None, optlevel=None, kind: Optional[str] = None):
35233541
"""
35243542
Create a pytables index on the specified columns
35253543
note: cannot index Time64Col() or ComplexCol currently;
35263544
PyTables must be >= 3.0
35273545
35283546
Parameters
35293547
----------
3530-
columns : False (don't create an index), True (create all columns
3531-
index), None or list_like (the indexers to index)
3532-
optlevel: optimization level (defaults to 6)
3533-
kind : kind of index (defaults to 'medium')
3548+
columns : None, bool, or listlike[str]
3549+
Indicate which columns to create an index on.
3550+
3551+
* False : Do not create any indexes.
3552+
* True : Create indexes on all columns.
3553+
* None : Create indexes on all columns.
3554+
* listlike : Create indexes on the given columns.
3555+
3556+
optlevel : int or None, default None
3557+
Optimization level, if None, pytables defaults to 6.
3558+
kind : str or None, default None
3559+
Kind of index, if None, pytables defaults to "medium"
35343560
35353561
Raises
35363562
------

0 commit comments

Comments
 (0)