Skip to content

Instantly share code, notes, and snippets.

@itruls
Created August 24, 2017 07:27
Show Gist options
  • Save itruls/457b5abd0c74c006af0da87176399dd8 to your computer and use it in GitHub Desktop.
Save itruls/457b5abd0c74c006af0da87176399dd8 to your computer and use it in GitHub Desktop.
Workshop Exercise 1 solution: Load data set from url
### EXERCISE: Load data set from url
# Load the Iris data set (directly) from it's [original source](https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data)
# using [pandas.read_csv](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html).
#
# Verify that the data is correct by comparing output from [pandas.DataFrame.describe](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.describe.html)
# on dataset you loaded with dataset loaded directly from scikit learn.
# SOLUTION
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
column_names = ['sepal length', 'sepal width', 'petal length', 'petal width', 'class']
my_iris = pd.read_csv(url, names=column_names)
print(my_iris.shape)
print(my_iris.head())
my_iris.describe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment