Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix performance degradation with line protocol #592

Merged
merged 1 commit into from
Jun 30, 2018
Merged
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
16 changes: 7 additions & 9 deletions 16 influxdb/_dataframe_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,18 @@ def _convert_dataframe_to_lines(self,

# Make an array of formatted field keys and values
field_df = dataframe[field_columns]
# Keep the positions where Null values are found
mask_null = field_df.isnull().values

field_df = self._stringify_dataframe(field_df,
numeric_precision,
datatype='field')

def format_line(line):
line = line[~line.isnull()] # drop None entries
return ",".join((line.index + '=' + line.values))

fields = field_df.apply(format_line, axis=1)
field_df = (field_df.columns.values + '=').tolist() + field_df
field_df[field_df.columns[1:]] = ',' + field_df[
field_df.columns[1:]]
field_df = field_df.where(~mask_null, '') # drop Null entries
fields = field_df.sum(axis=1)
del field_df

# Generate line protocol string
Expand All @@ -388,9 +390,6 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'):
# Prevent modification of input dataframe
dframe = dframe.copy()

# Keep the positions where Null values are found
mask_null = dframe.isnull().values

# Find int and string columns for field-type data
int_columns = dframe.select_dtypes(include=['integer']).columns
string_columns = dframe.select_dtypes(include=['object']).columns
Expand Down Expand Up @@ -435,7 +434,6 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'):

dframe.columns = dframe.columns.astype(str)

dframe = dframe.where(~mask_null, None)
return dframe

def _datetime_to_epoch(self, datetime, time_precision='s'):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.