Error in xpath expression when use pd.read_html to read a big html file

Viewed 331

I had store a dataframe as a html file(over 200MB) and try to read it in another notebook.

df_mar_html = pd.read_html('tweets_Mar.html')
df_mar = df_mar_html[0]
df_mar 

but the error just occur like this:

---------------------------------------------------------------------------
XPathEvalError                            Traceback (most recent call last)
<ipython-input-25-0d6731c6b345> in <module>()
----> 1 df_mar_html = pd.read_html('tweets_Mar.html')
      2 df_mar = df_mar_html[0]
      3 df_mar

3 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/html.py in _parse_tables(self, doc, match, kwargs)
    670             xpath_expr += _build_xpath_expr(kwargs)
    671 
--> 672         tables = doc.xpath(xpath_expr, namespaces=_re_namespace)
    673 
    674         tables = self._handle_hidden_tables(tables, "attrib")

src/lxml/etree.pyx in lxml.etree._Element.xpath()

src/lxml/xpath.pxi in lxml.etree.XPathElementEvaluator.__call__()

src/lxml/xpath.pxi in lxml.etree._XPathEvaluatorBase._handle_result()

XPathEvalError: Error in xpath expression

Same code works on another smaller dataframe/html file.

How could I solve this error or use other ways to read the dataframe within the html file?

0 Answers
Related