Skip to content

Commit de5de00

Browse files
committed
parametrize test
1 parent 34f45da commit de5de00

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pandas/core/computation/pytables.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,9 @@ def stringify(value):
230230
conv_val = conv_val.tz_convert("UTC")
231231
return TermValue(conv_val, conv_val._value, kind)
232232
elif kind.startswith("timedelta"):
233-
# TODO: other timedelta64 units? 2025-11-30 only
234-
# test_append_with_timedelta gets here
235233
unit = "ns"
236234
if "[" in kind:
237-
unit = cast("TimeUnit", kind[-3:-1])
235+
unit = cast("TimeUnit", kind.split("[")[-1][:-1])
238236
if isinstance(conv_val, str):
239237
conv_val = Timedelta(conv_val)
240238
elif lib.is_integer(conv_val) or lib.is_float(conv_val):

pandas/tests/io/pytables/test_append.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ def test_append_raise(tmp_path, using_infer_string):
848848
store.append("df", df)
849849

850850

851-
def test_append_with_timedelta(tmp_path):
851+
def test_append_with_timedelta(tmp_path, unit):
852852
# GH 3577
853853
# append timedelta
854854

@@ -860,6 +860,7 @@ def test_append_with_timedelta(tmp_path):
860860
}
861861
)
862862
df["C"] = df["A"] - df["B"]
863+
df["C"] = df["C"].astype(f"m8[{unit}]")
863864
df.loc[3:5, "C"] = np.nan
864865

865866
path = tmp_path / "test_append_with_timedelta.h5"

0 commit comments

Comments
 (0)