title: Python string formatting and UUID
body: <p>I am attempting to read in CSV data and map it to the following XML structure. In my first attempt, I have used % operator for string formatting, which works.</p>
  
  <pre><code>import pandas as pd
  import uuid
  df = pd.read_csv('media.csv', sep=',')
  def convert_row(row):
     return """&lt;video&gt;
      &lt;videoType fileUID="%s" name=""&gt;
          &lt;locationType&gt;&lt;/locationType&gt;
          &lt;type&gt;%s&lt;/type&gt;
          &lt;format&gt;%s&lt;/format&gt;
          &lt;year&gt;%s&lt;/year&gt;
      &lt;/videoType&gt;
  &lt;/video&gt;""" % (row[0], row[1], row[2], row[3])
  
  
  print '\n'.join(df.apply(convert_row, axis=1))
  </code></pre>
  
  <p>However, I am hoping to populate the <code>fileUID="%s"</code> with a generated uuid, that I can then reference elsewhere. I'm not able to get this to work.</p>
  
  <p>I tried adding <code>u = str(uuid.uuid4())</code> just before the return statement and update <code>% (u, row[0], row[1], row[2], row[3])</code></p>
  
  <p>I get a 'not all arguments converted during string formatting' error</p>
  
  <p>So I attempted to use f-strings formatting</p>
  
  <pre><code>import pandas as pd
  import uuid
  df = pd.read_csv('media.csv', sep=',')
  def convert_row(row):
     return f"""&lt;video&gt;
      &lt;videoType fileUID="{u}" name=""&gt;
          &lt;locationType&gt;&lt;/locationType&gt;
          &lt;type&gt;{row[0]}&lt;/type&gt;
          &lt;format&gt;{row[1]}&lt;/format&gt;
          &lt;year&gt;{row[2]}&lt;/year&gt;
      &lt;/videoType&gt;
  &lt;/video&gt;"""
  
  
  print '\n'.join(df.apply(convert_row, axis=1))
  </code></pre>
  
  <p>and get another error stating invalid syntax in regards to the closing <code>"""</code></p>
  
  <p>I guess my questions are which string formatting style is the best option when dealing with UUID and what is wrong with my code? Plus, if I wish to reference the generated uuid in other generated xml structures - I will ultimately create an xml file with the multiple generated xml structure content.</p>
  
  <p>Thank you for any assistance </p>