Skip to content

Commit b328071

Browse files
committed
fixes for mutable default parameters in dataframe
1 parent f9bd6cc commit b328071

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

influxdb/_dataframe_client.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def write_points(self,
4444
dataframe,
4545
measurement,
4646
tags=None,
47-
tag_columns=[],
48-
field_columns=[],
47+
tag_columns=None,
48+
field_columns=None,
4949
time_precision=None,
5050
database=None,
5151
retention_policy=None,
@@ -72,6 +72,10 @@ def write_points(self,
7272
figures for float and all significant figures for int datatypes.
7373
7474
"""
75+
if tag_columns is None:
76+
tag_columns = []
77+
if field_columns is None:
78+
field_columns = []
7579
if batch_size:
7680
number_batches = int(math.ceil(len(dataframe) / float(batch_size)))
7781
for batch in range(number_batches):
@@ -166,8 +170,8 @@ def _convert_dataframe_to_json(self,
166170
dataframe,
167171
measurement,
168172
tags=None,
169-
tag_columns=[],
170-
field_columns=[],
173+
tag_columns=None,
174+
field_columns=None,
171175
time_precision=None):
172176

173177
if not isinstance(dataframe, pd.DataFrame):
@@ -179,9 +183,9 @@ def _convert_dataframe_to_json(self,
179183
PeriodIndex.')
180184

181185
# Make sure tags and tag columns are correctly typed
182-
tag_columns = tag_columns if tag_columns else []
183-
field_columns = field_columns if field_columns else []
184-
tags = tags if tags else {}
186+
tag_columns = tag_columns if tag_columns is not None else []
187+
field_columns = field_columns if field_columns is not None else []
188+
tags = tags if tags is not None else {}
185189
# Assume field columns are all columns not included in tag columns
186190
if not field_columns:
187191
field_columns = list(
@@ -221,8 +225,8 @@ def _convert_dataframe_to_json(self,
221225
def _convert_dataframe_to_lines(self,
222226
dataframe,
223227
measurement,
224-
field_columns=[],
225-
tag_columns=[],
228+
field_columns=None,
229+
tag_columns=None,
226230
global_tags={},
227231
time_precision=None,
228232
numeric_precision=None):
@@ -242,6 +246,8 @@ def _convert_dataframe_to_lines(self,
242246
field_columns = []
243247
if tag_columns is None:
244248
tag_columns = []
249+
if global_tags is None:
250+
global_tags = {}
245251

246252
# Make sure field_columns and tag_columns are lists
247253
field_columns = list(field_columns) if list(field_columns) 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