Skip to content

Feature request "DataFrameClient" transfer from version 1.7 to 2 - Pandas dataframe not possible to ingest to influxdb 2  #79

Description

@Sutyke

Dear Great Maintainer,

I would like to request to transfer feature which is currently in Influxdb 1.7 to 2.0.

There are 2 proposals:

  1. Transfer DataFrameClient from 1.7 to 2

In the version 1.7, function DataFrameClient allows to insert the dataframe to idb.

import pandas as pd
from influxdb import DataFrameClient
dbConnDF = DataFrameClient('localhost', '8086', 'd', 'password', 'securities')
df = pd.read_parquet('/home/d/fi/01_Data/01_raw_data/qd.parquet').set_index('date').sort_values()
%time dbConnDF.write_points(df, 'securities', tag_columns=['symbol'], protocol="json", batch_size=10000)
%time d = dbConnDF.query("select * from securities")
d['securities']

  1. Create some helping function to change dataframe to format readable for influxdb 2

@Anaisdg created the function below.

https://github.com/Anaisdg/Influx_Pandas
**`import pandas as pd

import time
from datetime import datetime

def lp(df,measurement,tag_key,field,value,datetime):
    lines= [str(df[measurement][d]) + "," 
            + str(tag_key) + "=" + str(df[tag_key][d]) 
            + " " + str(df[field][d]) + "=" + str(df[value][d]) 
            + " " + str(int(time.mktime(df[datetime][d].timetuple()))) + "000000000" for d in range(len(df))]
    return lines`**

Thank you in advance for your help it will save a lot of time to your customers

Sutyke

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions