-
Notifications
You must be signed in to change notification settings - Fork 186
feat: DataFrame optimalization #97
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28b1fb7
feat: Optimize serializing Pandas DataFrame for writing #92
rolincova f613fc6
feat: Optimize serializing Pandas DataFrame for writing #92
rolincova 6a642ed
feat: Optimize serializing Pandas DataFrame for writing #92
rolincova 8de8ed9
feat: Optimize serializing Pandas DataFrame for writing #92
rolincova e7ff7a0
chore: check support of numpy.int64
bednar 3a56509
fix: disable not working tests
bednar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pandas>=0.25.3 | ||
numpy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import csv | ||
import os | ||
import time | ||
import unittest | ||
|
||
from influxdb_client import InfluxDBClient, WriteOptions, WriteApi, Point | ||
from tests.base_test import BaseTest | ||
|
||
|
||
class DataFrameWriteTest(BaseTest): | ||
|
||
def setUp(self) -> None: | ||
self.influxDb_client = InfluxDBClient(url="http://localhost:9999", token="my-token") | ||
|
||
self.write_options = WriteOptions(batch_size=10_000, flush_interval=5_000, retry_interval=3_000) | ||
self._write_client = WriteApi(influxdb_client=self.influxDb_client, write_options=self.write_options) | ||
|
||
def tearDown(self) -> None: | ||
self._write_client.__del__() | ||
|
||
@unittest.skip('Test big file') | ||
def test_write_data_frame(self): | ||
import random | ||
from influxdb_client.extras import pd | ||
|
||
if not os.path.isfile("data_frame_file.csv"): | ||
with open('data_frame_file.csv', mode='w+') as csv_file: | ||
_writer = csv.writer(csv_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) | ||
_writer.writerow(['time', 'col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8']) | ||
|
||
for i in range(1, 1500000): | ||
choice = ['test_a', 'test_b', 'test_c'] | ||
_writer.writerow([i, random.choice(choice), 'test', random.random(), random.random(), | ||
random.random(), random.random(), random.random(), random.random()]) | ||
|
||
csv_file.close() | ||
|
||
with open('data_frame_file.csv', mode='rb') as csv_file: | ||
|
||
data_frame = pd.read_csv(csv_file, index_col='time') | ||
print(data_frame) | ||
|
||
print('Writing...') | ||
|
||
start = time.time() | ||
|
||
self._write_client.write("my-bucket", "my-org", record=data_frame, | ||
data_frame_measurement_name='h2o_feet', | ||
data_frame_tag_columns=['location']) | ||
|
||
print("Time elapsed: ", (time.time() - start)) | ||
|
||
csv_file.close() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.