title: Python pandas append: InvalidIndexError: Reindexing only valid with uniquely valued Index objects
body: <p>I'm getting stuck with the below code where I want to append two dataframes, but returning me this error: InvalidIndexError: Reindexing only valid with uniquely valued Index objects
  and I cannot figure why :(</p>
  <p>Basically what I would like is to populate a dataframe by appending the results of a sparql query.</p>
  <p>Thank you in advance for any help.</p>
  <p>[Edit] I succeeded in doing this with a (ugly) workaround but I still don't understand what's the best way to create an empty dataframe and filling in with a for loop with the results of some functions returning a dataframe.</p>
  <p>Francesca</p>
  <pre><code>import pandas as pd
  import numpy as np
  import re
  
  from SPARQLWrapper import SPARQLWrapper, JSON
  
  def wikidata_sparql(url):
      resource = re.search(r'(?&lt;=\/)[^\/]+$',url).group()
      
      sparql = SPARQLWrapper(&quot;https://query.wikidata.org/sparql&quot;)
      sparql.setQuery(&quot;&quot;&quot;
              SELECT DISTINCT ?v ?mylang ?label ?instanceof ?instanceofLabel ?subclassof ?subclassofLabel ?hasuse ?hasuseLabel ?commonscategory ?commonscategoryLabel ?measurementscale ?measurementscaleLabel ?topicscategory ?topicscategoryLabel WHERE {
                {
                  BIND(wd:&quot;&quot;&quot;+resource+&quot;&quot;&quot; AS ?v)
                  VALUES ?mylang {
                    &quot;en&quot;
                  }
                  OPTIONAL {
                    wd:&quot;&quot;&quot;+resource+&quot;&quot;&quot; rdfs:label ?label.
                    FILTER(LANGMATCHES(LANG(?label), ?mylang))
                  }
                  OPTIONAL { ?v wdt:P31 ?instanceof. }
                  OPTIONAL { ?v wdt:P279 ?subclassof. }
                  OPTIONAL { ?v wdt:P366 ?hasuse. }
                  OPTIONAL { ?v wdt:P373 ?commonscategory. }
                  OPTIONAL { ?v wdt:P1880 ?measurementscale. }
                  OPTIONAL { ?v wdt:P910 ?topicscategory. }
                  SERVICE wikibase:label { bd:serviceParam wikibase:language &quot;en&quot;. }
                }
              }
      &quot;&quot;&quot;)
      
      sparql.setReturnFormat(JSON)
      results = sparql.query().convert()
      
      return results
  
  ## Wikidata to Dataframe
  col_names = [&quot;v.value&quot;,&quot;mylang.value&quot;,&quot;label.value&quot;,
               &quot;subclassof.value&quot;,&quot;subclassofLabel.value&quot;,
               &quot;topicscategory.value&quot;,&quot;topicscategoryLabel.value&quot;,
               &quot;commonscategory.value&quot;,&quot;commonscategoryLabel.value&quot;,
               &quot;subclassof.value&quot;,&quot;subclassofLabel.value&quot;]
  
  df_entities_wiki = pd.DataFrame(columns=col_names)
  
  results = wikidata_sparql(&quot;https://www.wikidata.org/wiki/Q3503313&quot;)
  
  col_names_subset = [i for i in col_names if i in pd.io.json.json_normalize(results['results']['bindings']).columns]
  col_names_subset = np.unique(col_names_subset)
  temp = pd.io.json.json_normalize(results['results']['bindings'])[col_names_subset]
  df_entities_wiki = df_entities_wiki.append(temp, ignore_index = True, sort = True, verify_integrity = False)
      
  </code></pre>