Skip to content

Commit baf6951

Browse files
committed
feat: support for writing pandas DataFrame (#79) - readme
1 parent aa49182 commit baf6951

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 1.7.0 [unreleased]
22

3+
### Features
4+
1. [#79](https://github.com/influxdata/influxdb-client-python/issues/79): Added support for writing Pandas DataFrame
5+
36
### Bug Fixes
47
1. [#85](https://github.com/influxdata/influxdb-client-python/issues/85): Fixed a possibility to generate empty write batch
58

README.rst

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ InfluxDB 2.0 client features
4949
- `Line Protocol <https://docs.influxdata.com/influxdb/v1.6/write_protocols/line_protocol_tutorial>`_
5050
- `Data Point <https://github.com/influxdata/influxdb-client-python/blob/master/influxdb_client/client/write/point.py#L16>`__
5151
- `RxPY <https://rxpy.readthedocs.io/en/latest/>`__ Observable
52+
- `Pandas DataFrame <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html>`_
5253
- `How to writes <#writes>`_
5354
- `InfluxDB 2.0 API <https://github.com/influxdata/influxdb/blob/master/http/swagger.yml>`_ client for management
5455
- the client is generated from the `swagger <https://github.com/influxdata/influxdb/blob/master/http/swagger.yml>`_ by using the `openapi-generator <https://github.com/OpenAPITools/openapi-generator>`_
@@ -219,6 +220,7 @@ The data could be written as
219220
3. Dictionary style mapping with keys: ``measurement``, ``tags``, ``fields`` and ``time``
220221
4. List of above items
221222
5. A ``batching`` type of write also supports an ``Observable`` that produce one of an above item
223+
6. `Pandas DataFrame <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html>`_
222224

223225

224226
Batching
@@ -302,6 +304,16 @@ The batching is configurable by ``write_options``\ :
302304
303305
_write_client.write("my-bucket", "my-org", _data)
304306
307+
"""
308+
Write Pandas DataFrame
309+
"""
310+
now = pd.Timestamp.now('UTC')
311+
data_frame = pd.DataFrame(data=[["coyote_creek", 1.0], ["coyote_creek", 2.0]],
312+
index=[now, now + timedelta(hours=1)],
313+
columns=["location", "water_level"])
314+
315+
self.write_client.write(bucket.name, record=data_frame, data_frame_measurement_name='h2o_feet',
316+
data_frame_tag_columns=['location'])
305317
306318
"""
307319
Close client

0 commit comments

Comments
 (0)