title: Parsing and extracting data into a pandas dataframe : BeautifulSoup and XML
body: <p>i hope you can help me with this , so i need to create a function that parse a text, and extract data into a pandas DataFrame:</p>
  
  <p>"""
      Function
      ---------
      rcp_poll_data</p>
  
  <pre><code>Extract poll information from an XML string, and convert to a DataFrame
  
  Parameters
  ----------
  xml : str
      A string, containing the XML data from a page like 
      get_poll_xml(1044)
  
  Returns
  -------
  A pandas DataFrame with the following columns:
      date: The date for each entry
      title_n: The data value for the gid=n graph (take the column name from the `title` tag)
  
  This DataFrame should be sorted by date
  
  Example
  -------
  Consider the following simple xml page:
  
  &lt;chart&gt;
  &lt;series&gt;
  &lt;value xid="0"&gt;1/27/2009&lt;/value&gt;
  &lt;value xid="1"&gt;1/28/2009&lt;/value&gt;
  &lt;/series&gt;
  &lt;graphs&gt;
  &lt;graph gid="1" color="#000000" balloon_color="#000000" title="Approve"&gt;
  &lt;value xid="0"&gt;63.3&lt;/value&gt;
  &lt;value xid="1"&gt;63.3&lt;/value&gt;
  &lt;/graph&gt;
  &lt;graph gid="2" color="#FF0000" balloon_color="#FF0000" title="Disapprove"&gt;
  &lt;value xid="0"&gt;20.0&lt;/value&gt;
  &lt;value xid="1"&gt;20.0&lt;/value&gt;
  &lt;/graph&gt;
  &lt;/graphs&gt;
  &lt;/chart&gt;
  
  Given this string, rcp_poll_data should return
  result = pd.DataFrame({'date': pd.to_datetime(['1/27/2009', '1/28/2009']), 
                         'Approve': [63.3, 63.3], 'Disapprove': [20.0, 20.0]})
  </code></pre>
  
  <h1>Mycode</h1>
  
  <pre><code>def rcp_poll_data(xml):
  soup = BeautifulSoup(xml,'xml')
  dates=soup.find("series")
  datesval=soup.findChildren(string=True)
  del datesval[-7:]
  obama=soup.find("graph",gid="1")
  obamaval={"title":obama["title"],"color":obama["color"]}
  romney=soup.find("graph",gid="2")
  romneyval={"title":romney["title"],"color":romney["color"]}
  result = pd.DataFrame({'date': pd.to_datetime(datesval,errors="ignore"), 'GID1':obamaval, 'GID2':romneyval})
  return result 
  </code></pre>
  
  <p>"""
  But i keep getting this error when i execute the program :
  Mixing dicts with non-Series may lead to ambiguous ordering.</p>
  
  <p>Please help !
  PS: the get_poll function is this :</p>
  
  <pre><code>def get_poll_xml(poll_id):
  url="http://charts.realclearpolitics.com/charts/"+str(poll_id)+".xml"
  return requests.get(url).content
  </code></pre>
  
  <p>poll_id=1044 for example</p>