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

add '' to categorical columns if not already in categories #505

Closed
wants to merge 9 commits into from
Closed
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
12 changes: 12 additions & 0 deletions influxdb/_dataframe_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from collections import defaultdict

import pandas as pd
import pandas.core.common as pdcom
import numpy as np

from .client import InfluxDBClient
Expand Down Expand Up @@ -343,6 +344,17 @@ def _convert_dataframe_to_lines(self,
tag_columns.append(tag)

tag_df = dataframe[tag_columns]
for tag_col_i in tag_columns:
if pdcom.is_categorical_dtype(tag_df[tag_col_i]):
if '' not in tag_df[tag_col_i].cat.categories:
tag_df[tag_col_i] = (tag_df[tag_col_i].cat.
add_categories('').
fillna('').
astype(str))
else:
tag_df[tag_col_i] = (tag_df[tag_col_i].
fillna('').
astype(str))
tag_df = tag_df.fillna('') # replace NA with empty string
tag_df = tag_df.sort_index(axis=1)
tag_df = self._stringify_dataframe(
Expand Down
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