turicreate.SGraph.select_fields

SGraph.select_fields(fields)

Return a new SGraph with only the selected fields. Other fields are discarded, while fields that do not exist in the SGraph are ignored.

Parameters:
fields : string | list [string]

A single field name or a list of field names to select.

Returns:
out : SGraph

A new graph whose vertex and edge data are projected to the selected fields.

Examples

>>> from turicreate import SGraph, Vertex
>>> verts = [Vertex(0, attr={'breed': 'labrador', 'age': 5}),
             Vertex(1, attr={'breed': 'labrador', 'age': 3}),
             Vertex(2, attr={'breed': 'vizsla', 'age': 8})]
>>> g = SGraph()
>>> g = g.add_vertices(verts)
>>> g2 = g.select_fields(fields=['breed'])