Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
adjoin,
pprint_thing,
)
from functools import lru_cache

if TYPE_CHECKING:
from collections.abc import (
Expand Down Expand Up @@ -1750,7 +1751,7 @@ def info(self) -> str:

if self.is_open:
lkeys = sorted(self.keys())
if len(lkeys):
if lkeys:
keys = []
values = []

Expand Down Expand Up @@ -2559,6 +2560,7 @@ def get_atom_string(cls, shape, itemsize):
return _tables().StringCol(itemsize=itemsize, shape=shape[0])

@classmethod
@lru_cache(maxsize=64)
def get_atom_coltype(cls, kind: str) -> type[Col]:
"""return the PyTables column class for this column"""
if kind.startswith("uint"):
Expand Down Expand Up @@ -4505,7 +4507,7 @@ def write_data(self, chunksize: int | None, dropna: bool = False) -> None:
masks.append(mask.astype("u1", copy=False))

# consolidate masks
if len(masks):
if masks:
mask = masks[0]
for m in masks[1:]:
mask = mask & m
Expand Down Expand Up @@ -4625,7 +4627,7 @@ def delete(
groups = list(diff[diff > 1].index)

# 1 group
if not len(groups):
if not groups:
groups = [0]

# final element
Expand Down Expand Up @@ -5091,7 +5093,7 @@ def _maybe_convert_for_string_atom(
if bvalues.dtype != object:
return bvalues

bvalues = cast(np.ndarray, bvalues)
bvalues = cast("np.ndarray", bvalues)

dtype_name = bvalues.dtype.name
inferred_type = lib.infer_dtype(bvalues, skipna=False)
Expand Down