{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ЛШКН День 2. Практика. Введение в Pandas" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "%pylab inline" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "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", "
ageworkclassfnlwgteducationeducation-nummarital-statusoccupationrelationshipracesexcapital-gaincapital-losshours-per-weeknative-countrysalary
032Private205019Assoc-acdm12Never-marriedSalesNot-in-familyBlackMale0050United-States<=50K
140Private121772Assoc-voc11Married-civ-spouseCraft-repairHusbandAsian-Pac-IslanderMale0040?>50K
234Private2454877th-8th4Married-civ-spouseTransport-movingHusbandAmer-Indian-EskimoMale0045Mexico<=50K
325Self-emp-not-inc176756HS-grad9Never-marriedFarming-fishingOwn-childWhiteMale0035United-States<=50K
432Private186824HS-grad9Never-marriedMachine-op-inspctUnmarriedWhiteMale0040United-States<=50K
\n", "
" ], "text/plain": [ " age workclass fnlwgt education education-num \\\n", "0 32 Private 205019 Assoc-acdm 12 \n", "1 40 Private 121772 Assoc-voc 11 \n", "2 34 Private 245487 7th-8th 4 \n", "3 25 Self-emp-not-inc 176756 HS-grad 9 \n", "4 32 Private 186824 HS-grad 9 \n", "\n", " marital-status occupation relationship race \\\n", "0 Never-married Sales Not-in-family Black \n", "1 Married-civ-spouse Craft-repair Husband Asian-Pac-Islander \n", "2 Married-civ-spouse Transport-moving Husband Amer-Indian-Eskimo \n", "3 Never-married Farming-fishing Own-child White \n", "4 Never-married Machine-op-inspct Unmarried White \n", "\n", " sex capital-gain capital-loss hours-per-week native-country salary \n", "0 Male 0 0 50 United-States <=50K \n", "1 Male 0 0 40 ? >50K \n", "2 Male 0 0 45 Mexico <=50K \n", "3 Male 0 0 35 United-States <=50K \n", "4 Male 0 0 40 United-States <=50K " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = pd.read_csv('adult.data.csv')\n", "data.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Сколько мужчин и женщин в датасете?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Средний возраст мужчины?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3. Какова доля граждан США?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 4. Постройте гистограмму распределения образования людей (bar plot) (education)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 5. Каковы среднее и среднеквадратичное отклонение для финального веса (fnlwgt) для разведённых людей? " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 6. Правда ли, что люди, которые получают больше 50k (salary) имеют минимум высшее образование?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 7. Какого минимальный и макимальный возраст для людей каждой расы и пола?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 9. Что больше: отношение числа мужчин бакалавров (bachelors) к числу мужчин магистров (masters) или такое же отношение для женщин?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 10. Какое максимальное число часов человек работает в неделю? Сколько людей работают такое количество часов и каков их доход?" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Local Python", "language": "python", "name": "local" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }