Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Adds time index type check compatible with py3.6
Browse files Browse the repository at this point in the history
Pandas dropped support for python 3.6 in something like 1.2.
So pandas 1.1.5 is what we're using in our CI system, and that
does not have the `NDArrayBackedExtensionIndex` type.

So I'm guessing here, but looking at the 1.1.5 source, we instead
want `ExtensionIndex`.
  • Loading branch information
skrawcz committed Sep 22, 2022
1 parent d4bf48e commit 23eb685
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hamilton/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ def pandas_index_types(
for output_name, output_value in outputs.items():
if isinstance(output_value, (pd.DataFrame, pd.Series)):
dict_key = f"{output_value.index.__class__.__name__}:::{output_value.index.dtype}"
if isinstance(output_value.index, pd_extension.NDArrayBackedExtensionIndex):
try:
index_type = getattr(pd_extension, "NDArrayBackedExtensionIndex")
except AttributeError: # for python 3.6 & pandas 1.1.5
index_type = getattr(pd_extension, "ExtensionIndex")
if isinstance(output_value.index, index_type):
# it's a time index -- these will produce garbage if not aligned properly.
time_indexes[dict_key].append(output_name)
else:
Expand Down

0 comments on commit 23eb685

Please sign in to comment.