Skip to content

Commit 8c88a7e

Browse files
author
tptaylor
committed
Speedup saving of Pandas Series/Dataframes with MultiIndex containing a
date.
1 parent 4f74ccb commit 8c88a7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arctic/store/_pandas_ndarray_store.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def _to_primitive(arr):
2121
if arr.dtype.hasobject:
2222
if len(arr) > 0:
2323
if isinstance(arr[0], Timestamp):
24-
return arr.astype(DTN64_DTYPE)
24+
return np.array([t.value for t in arr], dtype=DTN64_DTYPE)
2525
return np.array(list(arr))
2626
return arr
2727

@@ -35,7 +35,7 @@ def _index_to_records(self, df):
3535
if isinstance(index, MultiIndex):
3636
# array of tuples to numpy cols. copy copy copy
3737
if len(df) > 0:
38-
ix_vals = map(np.array, zip(*index.values))
38+
ix_vals = map(np.array, [index.get_level_values(i) for i in range(index.nlevels)])
3939
else:
4040
# empty multi index has no size, create empty arrays for recarry..
4141
ix_vals = [np.array([]) for n in index.names]

0 commit comments

Comments
 (0)