0

I am trying to create a function that will allow a user to perform a Breadth-first-search in Graphframes using the .bfs method. An example function looks like:

    Graphframe.bfs("name = 'Esther'", "relationship = 'friend'")

I would like a function to work like:

    def friendZone(person, affiliation):
         Graphframe.bfs("name = 'person'", "relationship = 'affiliation'")

I have tried using a concat method like:

     '"' + "name='" + person + "'" + '"'

, but that has not worked. I also tried using

'"name={}"'.format(person).  

Help please?

khelwood
  • 55,782
  • 14
  • 81
  • 108

1 Answers1

1

You can use an f-string

def friendZone(person, affiliation):
         Graphframe.bfs(f"name = {person}", "relationship = {affiliation}")
  • Thank you! This didn't specifically fix my problem, but it did lead me to the solution. I ended up using "name='%s'"% person, which worked perfectly. – SensingFailure Feb 06 '20 at 21:37