3

The code used is

import pandas as pd
url = 'https://raw.githubusercontent.com/RInterested/datasets/gh-pages/mtcars.csv'
dataframe = pd.read_csv(url)
isinstance(dataframe, pd.DataFrame) # This lets me know the data is successfully imported as a DF.
dataframe.head()

But is this last line the spits out an unexpected error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/IPython/core/formatters.py in __call__(self, obj)
    336             method = get_real_method(obj, self.print_method)
    337             if method is not None:
--> 338                 return method()
    339             return None
    340         else:

1 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/formats/format.py in to_html(self, buf, encoding, classes, notebook, border)
    977             if (i >= nlevels and self.fmt.index and self.multirow and
    978                     ilevels > 1):
--> 979                 # sum up rows to multirows
    980                 crow = self._format_multirow(crow, ilevels, i, strrows)
    981             buf.write(' & '.join(crow))

ModuleNotFoundError: No module named 'pandas.io.formats.html'

The suggested SO question to resolve the issue deals with the error:

ModuleNotFoundError: No module named 'pandas.io.formats.csvs'

which seems different.

3
  • 2
    It's working for me. What version of python and pandas are you using? Commented May 21, 2020 at 20:10
  • @NYCCoder 1.0.3 Commented May 21, 2020 at 20:30
  • @NYCCoder !pip install --upgrade pandas did the trick! Commented May 21, 2020 at 20:32

1 Answer 1

1

It's working for me. Maybe you need to update your python. But here is an alternative solution. Try this:

import pandas as pd
import io
import requests

url = "https://raw.githubusercontent.com/RInterested/datasets/gh-pages/mtcars.csv"
contents = requests.get(url).content
df = pd.read_csv(io.StringIO(contents.decode('utf-8')))
isinstance(df, pd.DataFrame) 
df.head()

I hope this will work fine. :)

Sign up to request clarification or add additional context in comments.

2 Comments

I'm still getting this error: ModuleNotFoundError: No module named 'pandas.io.formats.html'
Then maybe you should try to uninstall pandas and reinstall it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.