- 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 exists, or is empty then a new vertex will be added. If no ~label column exists an exception will be thrown. DataFrames for edges must have a ~id, ~label, ~to, and ~from column. If the ~id column does not exist the specified id does not exists, or is empty then a new edge will be added. If no ~label, ~to, or ~from column exists an 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 setting by setting use_header_cardinality=False.
client (NeptuneClient) – instance of the neptune client to use
df (pandas.DataFrame) – Pandas DataFrame https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
batch_size (int) – The number of rows to save at a time. Default 50
use_header_cardinality (bool) – If True, then the header cardinality will be used to save the data. Default True
True if records were written
- Return type
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 ... )