|
1 | 1 | from mock import Mock, sentinel, patch
|
2 |
| -import numpy as np |
3 |
| -import pandas as pd |
| 2 | +from pandas.util.testing import assert_frame_equal |
4 | 3 | from pytest import raises
|
5 | 4 |
|
6 | 5 | from arctic.store._pandas_ndarray_store import PandasStore, \
|
7 | 6 | PandasDataFrameStore, PandasPanelStore
|
| 7 | +import numpy as np |
| 8 | +import pandas as pd |
| 9 | +from tests.util import read_str_as_pandas |
8 | 10 |
|
9 | 11 |
|
10 | 12 | def test_can_convert_to_records_without_objects_returns_false_on_exception_in_to_records():
|
@@ -87,3 +89,18 @@ def test_raises_upon_empty_panel_write():
|
87 | 89 | panel = Mock(shape=(1, 0, 3))
|
88 | 90 | with raises(ValueError):
|
89 | 91 | store.write(sentinel.mlib, sentinel.version, sentinel.symbol, panel, sentinel.prev)
|
| 92 | + |
| 93 | + |
| 94 | +def test_read_multi_index_with_no_ts_info(): |
| 95 | + # github #81: old multi-index ts would not have tz info in metadata. Ensure read is not broken |
| 96 | + df = read_str_as_pandas("""index 1 | index 2 | SPAM |
| 97 | + 2012-09-08 | 2015-01-01 | 1.0 |
| 98 | + 2012-09-09 | 2015-01-02 | 1.1 |
| 99 | + 2012-10-08 | 2015-01-03 | 2.0""", num_index=2) |
| 100 | + store = PandasDataFrameStore() |
| 101 | + record = store.to_records(df)[0] |
| 102 | + |
| 103 | + # now take away timezone info from metadata |
| 104 | + record = np.array(record.tolist(), dtype=np.dtype([('index 1', '<M8[ns]'), ('index 2', '<M8[ns]'), ('SPAM', '<f8')], |
| 105 | + metadata={'index': ['index 1', 'index 2'], 'columns': ['SPAM']})) |
| 106 | + assert store._index_from_records(record).equals(df.index) |
0 commit comments