Skip to content

Commit 07b5f84

Browse files
Merge pull request pandas-dev#38 from manahl/MDP-571-slow-multi-index-saves
Speedup saving of Pandas Series/Dataframes with MultiIndex containing a date
2 parents 4f74ccb + 12c6f62 commit 07b5f84

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGES.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11

22
## Changelog
33

4+
### 1.11 (2015-10-29)
5+
6+
* Bugfix: Improve performance of saving multi-index Pandas DataFrames
7+
by 9x
8+
9+
### 1.10 (2015-10-28)
10+
11+
* Bugfix: VersionStore.read(date_range=...) could do the wrong thing with
12+
TimeZones (which aren't yet supported for date_range slicing.).
13+
414
### 1.9 (2015-10-06)
515

616
* Bugfix: fix authentication race condition when sharing an Arctic

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)