{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from sklearn.datasets import load_iris" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "iris = load_iris()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "iris_dataframe = pd.DataFrame(data= np.c_[iris['data'], iris['target']],\n", " columns= iris['feature_names'] + ['target'])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "iris_dataframe['species'] = pd.Categorical.from_codes(iris.target, \n", " iris.target_names)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sepal length (cm)sepal width (cm)petal length (cm)petal width (cm)targetspecies
05.13.51.40.20.0setosa
14.93.01.40.20.0setosa
24.73.21.30.20.0setosa
34.63.11.50.20.0setosa
45.03.61.40.20.0setosa
55.43.91.70.40.0setosa
64.63.41.40.30.0setosa
75.03.41.50.20.0setosa
84.42.91.40.20.0setosa
94.93.11.50.10.0setosa
105.43.71.50.20.0setosa
114.83.41.60.20.0setosa
124.83.01.40.10.0setosa
134.33.01.10.10.0setosa
145.84.01.20.20.0setosa
155.74.41.50.40.0setosa
165.43.91.30.40.0setosa
175.13.51.40.30.0setosa
185.73.81.70.30.0setosa
195.13.81.50.30.0setosa
205.43.41.70.20.0setosa
215.13.71.50.40.0setosa
224.63.61.00.20.0setosa
235.13.31.70.50.0setosa
244.83.41.90.20.0setosa
255.03.01.60.20.0setosa
265.03.41.60.40.0setosa
275.23.51.50.20.0setosa
285.23.41.40.20.0setosa
294.73.21.60.20.0setosa
.....................
1206.93.25.72.32.0virginica
1215.62.84.92.02.0virginica
1227.72.86.72.02.0virginica
1236.32.74.91.82.0virginica
1246.73.35.72.12.0virginica
1257.23.26.01.82.0virginica
1266.22.84.81.82.0virginica
1276.13.04.91.82.0virginica
1286.42.85.62.12.0virginica
1297.23.05.81.62.0virginica
1307.42.86.11.92.0virginica
1317.93.86.42.02.0virginica
1326.42.85.62.22.0virginica
1336.32.85.11.52.0virginica
1346.12.65.61.42.0virginica
1357.73.06.12.32.0virginica
1366.33.45.62.42.0virginica
1376.43.15.51.82.0virginica
1386.03.04.81.82.0virginica
1396.93.15.42.12.0virginica
1406.73.15.62.42.0virginica
1416.93.15.12.32.0virginica
1425.82.75.11.92.0virginica
1436.83.25.92.32.0virginica
1446.73.35.72.52.0virginica
1456.73.05.22.32.0virginica
1466.32.55.01.92.0virginica
1476.53.05.22.02.0virginica
1486.23.45.42.32.0virginica
1495.93.05.11.82.0virginica
\n", "

150 rows × 6 columns

\n", "
" ], "text/plain": [ " sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) \\\n", "0 5.1 3.5 1.4 0.2 \n", "1 4.9 3.0 1.4 0.2 \n", "2 4.7 3.2 1.3 0.2 \n", "3 4.6 3.1 1.5 0.2 \n", "4 5.0 3.6 1.4 0.2 \n", "5 5.4 3.9 1.7 0.4 \n", "6 4.6 3.4 1.4 0.3 \n", "7 5.0 3.4 1.5 0.2 \n", "8 4.4 2.9 1.4 0.2 \n", "9 4.9 3.1 1.5 0.1 \n", "10 5.4 3.7 1.5 0.2 \n", "11 4.8 3.4 1.6 0.2 \n", "12 4.8 3.0 1.4 0.1 \n", "13 4.3 3.0 1.1 0.1 \n", "14 5.8 4.0 1.2 0.2 \n", "15 5.7 4.4 1.5 0.4 \n", "16 5.4 3.9 1.3 0.4 \n", "17 5.1 3.5 1.4 0.3 \n", "18 5.7 3.8 1.7 0.3 \n", "19 5.1 3.8 1.5 0.3 \n", "20 5.4 3.4 1.7 0.2 \n", "21 5.1 3.7 1.5 0.4 \n", "22 4.6 3.6 1.0 0.2 \n", "23 5.1 3.3 1.7 0.5 \n", "24 4.8 3.4 1.9 0.2 \n", "25 5.0 3.0 1.6 0.2 \n", "26 5.0 3.4 1.6 0.4 \n", "27 5.2 3.5 1.5 0.2 \n", "28 5.2 3.4 1.4 0.2 \n", "29 4.7 3.2 1.6 0.2 \n", ".. ... ... ... ... \n", "120 6.9 3.2 5.7 2.3 \n", "121 5.6 2.8 4.9 2.0 \n", "122 7.7 2.8 6.7 2.0 \n", "123 6.3 2.7 4.9 1.8 \n", "124 6.7 3.3 5.7 2.1 \n", "125 7.2 3.2 6.0 1.8 \n", "126 6.2 2.8 4.8 1.8 \n", "127 6.1 3.0 4.9 1.8 \n", "128 6.4 2.8 5.6 2.1 \n", "129 7.2 3.0 5.8 1.6 \n", "130 7.4 2.8 6.1 1.9 \n", "131 7.9 3.8 6.4 2.0 \n", "132 6.4 2.8 5.6 2.2 \n", "133 6.3 2.8 5.1 1.5 \n", "134 6.1 2.6 5.6 1.4 \n", "135 7.7 3.0 6.1 2.3 \n", "136 6.3 3.4 5.6 2.4 \n", "137 6.4 3.1 5.5 1.8 \n", "138 6.0 3.0 4.8 1.8 \n", "139 6.9 3.1 5.4 2.1 \n", "140 6.7 3.1 5.6 2.4 \n", "141 6.9 3.1 5.1 2.3 \n", "142 5.8 2.7 5.1 1.9 \n", "143 6.8 3.2 5.9 2.3 \n", "144 6.7 3.3 5.7 2.5 \n", "145 6.7 3.0 5.2 2.3 \n", "146 6.3 2.5 5.0 1.9 \n", "147 6.5 3.0 5.2 2.0 \n", "148 6.2 3.4 5.4 2.3 \n", "149 5.9 3.0 5.1 1.8 \n", "\n", " target species \n", "0 0.0 setosa \n", "1 0.0 setosa \n", "2 0.0 setosa \n", "3 0.0 setosa \n", "4 0.0 setosa \n", "5 0.0 setosa \n", "6 0.0 setosa \n", "7 0.0 setosa \n", "8 0.0 setosa \n", "9 0.0 setosa \n", "10 0.0 setosa \n", "11 0.0 setosa \n", "12 0.0 setosa \n", "13 0.0 setosa \n", "14 0.0 setosa \n", "15 0.0 setosa \n", "16 0.0 setosa \n", "17 0.0 setosa \n", "18 0.0 setosa \n", "19 0.0 setosa \n", "20 0.0 setosa \n", "21 0.0 setosa \n", "22 0.0 setosa \n", "23 0.0 setosa \n", "24 0.0 setosa \n", "25 0.0 setosa \n", "26 0.0 setosa \n", "27 0.0 setosa \n", "28 0.0 setosa \n", "29 0.0 setosa \n", ".. ... ... \n", "120 2.0 virginica \n", "121 2.0 virginica \n", "122 2.0 virginica \n", "123 2.0 virginica \n", "124 2.0 virginica \n", "125 2.0 virginica \n", "126 2.0 virginica \n", "127 2.0 virginica \n", "128 2.0 virginica \n", "129 2.0 virginica \n", "130 2.0 virginica \n", "131 2.0 virginica \n", "132 2.0 virginica \n", "133 2.0 virginica \n", "134 2.0 virginica \n", "135 2.0 virginica \n", "136 2.0 virginica \n", "137 2.0 virginica \n", "138 2.0 virginica \n", "139 2.0 virginica \n", "140 2.0 virginica \n", "141 2.0 virginica \n", "142 2.0 virginica \n", "143 2.0 virginica \n", "144 2.0 virginica \n", "145 2.0 virginica \n", "146 2.0 virginica \n", "147 2.0 virginica \n", "148 2.0 virginica \n", "149 2.0 virginica \n", "\n", "[150 rows x 6 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "iris_dataframe" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }