Session Ready
Exercise

Importing flat files from the web: your turn!

You are about to import your first file from the web! The flat file you will import will be 'winequality-red.csv' from the University of California, Irvine's Machine Learning repository. The flat file contains tabular data of physiochemical properties of red wine, such as pH, alcohol content and citric acid content, along with wine quality rating.

The URL of the file is

'http://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv'

After you import it, you'll check your working directory to confirm that it is there and then you'll load it into a pandas DataFrame.

Instructions
100 XP
  • Import the function urlretrieve from the subpackage urllib.request.
  • Assign the URL of the file to the variable url.
  • Use the function urlretrieve() to save the file locally as 'winequality-red.csv'.
  • Execute the remaining code to load 'winequality-red.csv' in a pandas DataFrame and to print its head to the shell.