Skip to content

Commit 31734ee

Browse files
authored
Merge pull request pandas-dev#592 from dimosped/fix-tickstore-timezone
fixed the index timezone not being in the local timezone
2 parents 7b9a31d + 269599a commit 31734ee

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Feature: #571 Removed the Cython LZ4 code, use the latest python-lz4
66
* Feature: #557 Threadpool based compression. Speed imrpovement and tuning benchmarks.
77
* Bugfix: fix tickstore unicode handling, support both unicode and utf-8 arrays
8+
* Bugfix: #591 Fix tickstore reads not returning index with localized timezone
89
* Feature: #595 add host attribute to VersionedItem.
910

1011
### 1.67.1 (2018-07-11)

arctic/tickstore/tickstore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def read(self, symbol, date_range=None, columns=None, include_images=False, allo
350350
mgr = _arrays_to_mgr(arrays, columns, index, columns, dtype=None)
351351
rtn = pd.DataFrame(mgr)
352352
# Present data in the user's default TimeZone
353-
rtn.index.tz_convert(mktz())
353+
rtn.index = rtn.index.tz_convert(mktz())
354354

355355
t = (dt.now() - perf_start).total_seconds()
356356
ticks = len(rtn)

tests/integration/test_compress_integration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ def test_exceptions():
7070
with pytest.raises(Exception) as e:
7171
c.decompress_array(data)
7272
assert ("decompressor wrote" in str(e).lower() or "corrupt input at" in str(e).lower() or "decompression failed: corrupt input" in str(e).lower())
73+

tests/integration/tickstore/test_ts_read.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def test_read(tickstore_lib):
4646
assert_array_equal(df['PRICE'].values, np.array([1545, 1543.75]))
4747
assert_array_equal(df.index.values.astype('object'), np.array([1185076787070000000, 1185141600600000000]))
4848
assert tickstore_lib._collection.find_one()['c'] == 2
49+
assert df.index.tzinfo == mktz()
4950

5051

5152
def test_read_data_is_modifiable(tickstore_lib):
@@ -185,6 +186,8 @@ def test_read_all_cols_all_dtypes(tickstore_lib, chunk_size):
185186
tickstore_lib.write('sym', data)
186187
df = tickstore_lib.read('sym', columns=None)
187188

189+
assert df.index.tzinfo == mktz()
190+
188191
# The below is probably more trouble than it's worth, but we *should*
189192
# be able to roundtrip data and get the same answer...
190193

@@ -323,13 +326,18 @@ def test_date_range_default_timezone(tickstore_lib, tz_name):
323326
tickstore_lib._chunk_size = 1
324327
tickstore_lib.write('SYM', DUMMY_DATA)
325328
df = tickstore_lib.read('SYM', date_range=DateRange(20130101, 20130701), columns=None)
329+
330+
assert df.index.tzinfo == mktz()
331+
326332
assert len(df) == 2
327333
assert df.index[1] == dt(2013, 7, 1, tzinfo=mktz(tz_name))
328334
df = tickstore_lib.read('SYM', date_range=DateRange(20130101, 20130101), columns=None)
329335
assert len(df) == 1
336+
assert df.index.tzinfo == mktz()
330337

331338
df = tickstore_lib.read('SYM', date_range=DateRange(20130701, 20130701), columns=None)
332339
assert len(df) == 1
340+
assert df.index.tzinfo == mktz()
333341

334342

335343
def test_date_range_no_bounds(tickstore_lib):

0 commit comments

Comments
 (0)