Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added possibility to use datetime nanoseconds precision by pandas.Timestamp #141

Merged
merged 3 commits into from
Aug 11, 2020

Conversation

bednar
Copy link
Contributor

@bednar bednar commented Aug 7, 2020

Closes #124

Proposed Changes

The Python's datetime doesn't support precision with nanoseconds so the library during writes and queries ignores everything after microseconds.

If you would like to use datetime with nanosecond precision you should use pandas.Timestamp that is replacement for python datetime.datetime object and also you should set a proper DateTimeHelper to the client.

from influxdb_client import Point, InfluxDBClient
from influxdb_client.client.util.date_utils_pandas import PandasDateTimeHelper
from influxdb_client.client.write_api import SYNCHRONOUS

"""
Set PandasDate helper which supports nanoseconds.
"""
import influxdb_client.client.util.date_utils as date_utils

date_utils.date_helper = PandasDateTimeHelper()

...

https://github.com/influxdata/influxdb-client-python/blob/feat/nanoseconds/examples/nanosecond_precision.py

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are in semantic format
  • Sign CLA (if not already signed)

@bednar bednar requested review from rhajek and rolincova August 7, 2020 09:16
@codecov-commenter
Copy link

codecov-commenter commented Aug 7, 2020

Codecov Report

Merging #141 into master will increase coverage by 0.01%.
The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #141      +/-   ##
==========================================
+ Coverage   88.93%   88.94%   +0.01%     
==========================================
  Files          23       24       +1     
  Lines        1870     1882      +12     
==========================================
+ Hits         1663     1674      +11     
- Misses        207      208       +1     
Impacted Files Coverage Δ
influxdb_client/client/util/date_utils.py 94.73% <94.73%> (ø)
influxdb_client/client/flux_csv_parser.py 91.71% <100.00%> (ø)
influxdb_client/client/util/date_utils_pandas.py 100.00% <100.00%> (ø)
influxdb_client/client/write/point.py 98.36% <100.00%> (-0.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d5f2c2...55492c5. Read the comment docs.

@bednar bednar marked this pull request as ready for review August 7, 2020 09:25
@bednar bednar added the enhancement New feature or request label Aug 7, 2020
@bednar bednar merged commit bfa0ac4 into master Aug 11, 2020
@bednar bednar deleted the feat/nanoseconds branch August 11, 2020 14:30
@bednar bednar added this to the 1.10.0 milestone Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nanoseconds ignored when writing Points with RFC string format
3 participants