Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix Travis and Panda tz_localize #679

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ python:
- "2.7"
- "3.5"
- "3.6"
- "pypy-5.3.1"
- "pypy"
- "pypy3"

env:
- INFLUXDB_VER=1.2.4
- INFLUXDB_VER=1.3.9
- INFLUXDB_VER=1.4.2
- INFLUXDB_VER=1.5.4
- INFLUXDB_VER=1.7.2

addons:
apt:
Expand Down
3 changes: 2 additions & 1 deletion influxdb/_dataframe_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def _to_dataframe(self, rs, dropna=True):
df = pd.DataFrame(data)
df.time = pd.to_datetime(df.time)
df.set_index('time', inplace=True)
df.index = df.index.tz_localize('UTC')
if df.index.tzinfo is None:
df.index = df.index.tz_localize('UTC')
df.index.name = None
result[key].append(df)
for key, data in result.items():
Expand Down
15 changes: 10 additions & 5 deletions influxdb/tests/dataframe_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,13 +818,15 @@ def test_query_into_dataframe(self):
pd1 = pd.DataFrame(
[[23422]], columns=['value'],
index=pd.to_datetime(["2009-11-10T23:00:00Z"]))
pd1.index = pd1.index.tz_localize('UTC')
if pd1.index.tzinfo is None:
pd1.index = pd1.index.tz_localize('UTC')
pd2 = pd.DataFrame(
[[23422], [23422], [23422]], columns=['value'],
index=pd.to_datetime(["2009-11-10T23:00:00Z",
"2009-11-10T23:00:00Z",
"2009-11-10T23:00:00Z"]))
pd2.index = pd2.index.tz_localize('UTC')
if pd2.index.tzinfo is None:
pd2.index = pd2.index.tz_localize('UTC')
expected = {
('network', (('direction', ''),)): pd1,
('network', (('direction', 'in'),)): pd2
Expand Down Expand Up @@ -871,11 +873,14 @@ def test_multiquery_into_dataframe(self):
index=pd.to_datetime([
"2015-01-29 21:55:43.702900257+0000",
"2015-01-29 21:55:43.702900257+0000",
"2015-06-11 20:46:02+0000"])).tz_localize('UTC')
"2015-06-11 20:46:02+0000"]))
if pd1.index.tzinfo is None:
pd1.index = pd1.index.tz_localize('UTC')
pd2 = pd.DataFrame(
[[3]], columns=['count'],
index=pd.to_datetime(["1970-01-01 00:00:00+00:00"]))\
.tz_localize('UTC')
index=pd.to_datetime(["1970-01-01 00:00:00+00:00"]))
if pd2.index.tzinfo is None:
pd2.index = pd2.index.tz_localize('UTC')
expected = [{'cpu_load_short': pd1}, {'cpu_load_short': pd2}]

cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ commands = nosetests -v --with-doctest {posargs}
deps =
flake8
pep8-naming
commands = flake8 --ignore=W503,W504,W605,N802,F821 influxdb
commands = flake8 --ignore=W503,W504,W605,N802,N816,F821 influxdb

[testenv:pep257]
deps = pydocstyle
Expand Down