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

Commit 6d60f44

Browse files
committed
Fix influxdb08 dataframe client flake8 errors.
1 parent dadb6c4 commit 6d60f44

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

influxdb/influxdb08/dataframe_client.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
from .client import InfluxDBClient
99

10+
try:
11+
import pandas as pd
12+
except ImportError as ex:
13+
raise ImportError('DataFrameClient requires Pandas, '
14+
'"{ex}" problem importing'.format(ex=str(ex)))
15+
try:
16+
import numpy as np
17+
except ImportError as ex:
18+
raise ImportError('DataFrameClient requires Numpy, '
19+
'"{ex}" problem importing'.format(ex=str(ex)))
20+
1021

1122
class DataFrameClient(InfluxDBClient):
1223
"""
@@ -17,22 +28,6 @@ class DataFrameClient(InfluxDBClient):
1728

1829
def __init__(self, ignore_nan=True, *args, **kwargs):
1930
super(DataFrameClient, self).__init__(*args, **kwargs)
20-
try:
21-
global pd
22-
import pandas as pd
23-
except ImportError as ex:
24-
raise ImportError(
25-
'DataFrameClient requires Pandas, "{ex}" problem importing'
26-
.format(ex=str(ex))
27-
)
28-
try:
29-
global np
30-
import numpy as np
31-
except ImportError as ex:
32-
raise ImportError(
33-
'DataFrameClient requires Numpy, "{ex}" problem importing'
34-
.format(ex=str(ex))
35-
)
3631

3732
self.EPOCH = pd.Timestamp('1970-01-01 00:00:00.000+00:00')
3833
self.ignore_nan = ignore_nan
@@ -149,7 +144,8 @@ def _convert_dataframe_to_json(self, dataframe, name, time_precision='s'):
149144

150145
def _convert_array(self, array):
151146
if self.ignore_nan:
152-
condition = (all(isinstance(el, (int, float, np.number)) for el in array) and
147+
number_types = (int, float, np.number)
148+
condition = (all(isinstance(el, number_types) for el in array) and
153149
np.isnan(array))
154150
return list(np.where(condition, None, array))
155151
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy