Skip to content

Instantly share code, notes, and snippets.

@jovianlin
Created March 27, 2017 15:14
Show Gist options
  • Save jovianlin/de731e728dec486fc50a5e8bbd43da83 to your computer and use it in GitHub Desktop.
Save jovianlin/de731e728dec486fc50a5e8bbd43da83 to your computer and use it in GitHub Desktop.
test_graphframes.py
# Create a Vertex DataFrame with unique ID column "id"
v = sqlContext.createDataFrame([
("a", "Alice", 34),
("b", "Bob", 36),
("c", "Charlie", 30),
], ["id", "name", "age"])
# Create an Edge DataFrame with "src" and "dst" columns
e = sqlContext.createDataFrame([
("a", "b", "friend"),
("b", "c", "follow"),
("c", "b", "follow"),
], ["src", "dst", "relationship"])
# Create a GraphFrame
from graphframes import *
g = GraphFrame(v, e)
g.inDegrees.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment