-
Notifications
You must be signed in to change notification settings - Fork 524
Dataframe client support for (i) tag columns and (ii) direct conversion to line protocol #364
Conversation
Python2.7 build is failing because Travis can't install pandas:
The cache might need to be cleared: I can also try running a build with no cache. |
datatype='field'): | ||
|
||
# Find int and string columns for field-type data | ||
int_columns = dataframe.select_dtypes(include=['int']).columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to include=['integer']
so other integer subtypes won't be treated as floats?
@tzonghao : This change has been made, along with some other small improvements to Also, for some reason, tox tests on my machine expect a retention policy duration of '0s' instead of '0' in |
@mdbartos Awesome pull request, it definitely makes things faster and easier. Thank you. |
time_precision, | ||
database, | ||
retention_policy, | ||
protocol='line') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be protocol=protocol
@tzonghao Thank you for reviewing this! |
Thanks again for reviewing @tzonghao. These changes have been made. |
Thank you @mdbartos |
One last thing: I edited the travis.yml file to get the build to work properly, but it should probably be changed back to the way it was (also, the travis cache should be cleared to allow pandas to build properly on 2.7). |
Yeah, I had noticed and was planning to fix it. |
Hi I am new to influxdb. When I am trying to insert a dataframe into influxdb i am getting "NameError: name '_convert_dataframe_to_lines' is not defined" error. In my code i have imported "from influxdb import dataframe_client"
I have checked that _dataframe_client.py exists. But anyway I can't figure it out how to execute it |
This pull request addresses issues #362 and #363.
tag_columns
andfield_columns
can now be specified in thewrite_points
method, allowing some columns to be treated as tags and others to be treated as fields. Global tags can still be specified using thetags
keyword argument (meaning that this change shouldn't break any old code).Additions:
_dataframe_client.py
_convert_dataframe_to_lines
: Converts dataframe to line protocol._stringify_dataframe
: Helper function for converting dataframe to string type.write_points
: Added protocol ('line' or 'json') and numeric precision keyword args._convert_dataframe_to_json
: Tag columns can now be specified.client.py
write
: Added protocol ('line' or 'json') keyword arg, and support for direct line protocol.write_points
: Same as write._write_points
: Same as write.send_packet
: Same as write.dataframe_client_test.py
test_write_points_from_dataframe_with_tag_columns
: Self-explanatory.test_write_points_from_dataframe_with_tag_cols_and_global_tags
: Self-explanatory.test_write_points_from_dataframe_with_tag_cols_and_defaults
: Tests default behavior (i.e. when tag columns are specified, but field columns aren't, etc.)test_write_points_from_dataframe_with_numeric_precision
: Tests for correct numeric precision behavior.(all tests)
: Inexpected_response
, order of tags/fields was changed to match the order they appear in the dataframe (for more consistent testing)Tag/field columns default behavior:
dataframe_client_test/test_write_points_with_tag_columns_and_defaults
for examples of expected behavior.Minor issues:
_convert_dataframe_to_json
in for the time being, but it can probably be removed.When you get time to review, please let me know if you have any questions or concerns.
Thanks,
MDB