awswrangler.neptune.to_property_graph¶
- awswrangler.neptune.to_property_graph(client: NeptuneClient, df: DataFrame, batch_size: int = 50, use_header_cardinality: bool = True) bool ¶
Write records stored in a DataFrame into Amazon Neptune.
If writing to a property graph then DataFrames for vertices and edges must be written separately.
DataFrames for vertices must have a ~label column with the label and a ~id column for the vertex id. If the ~id column does not exist, the specified id does not exist, or is empty then a new vertex will be added.
DataFrames for edges must have a ~id, ~label, ~to, and ~from column. If the ~id column does not exist the specified id does not exist, or is empty then a new edge will be added.
Existing ~id values will be overwritten. If no ~id, ~label, ~to, or ~from column exists, an InvalidArgumentValue exception will be thrown.
If you would like to save data using single cardinality then you can postfix (single) to the column header and set
use_header_cardinality=True
(default). e.g. A column named name(single) will save the name property as single cardinality. You can disable this by settinguse_header_cardinality=False
.- Parameters:
client (
NeptuneClient
) – instance of the neptune client to usedf (
DataFrame
) – Pandas DataFramebatch_size (
int
) – The number of rows to save at a time. Default 50use_header_cardinality (
bool
) – If True, then the header cardinality will be used to save the data. Default True
- Return type:
bool
- Returns:
True if records were written
Examples
Writing to Amazon Neptune
>>> import awswrangler as wr >>> client = wr.neptune.connect(neptune_endpoint, neptune_port, iam_enabled=False) >>> wr.neptune.gremlin.to_property_graph( ... df=df ... )