{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 파이썬 pandas 기초 연습문제"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 싸이그래머 : 생물심리Py\n",
    "* 작성자 : 김무성    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 차례"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 기초\n",
    "* 응용"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 기초 [1, 2, 3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* numpy 기초\n",
    "  - (numpy 기본) 문제 1. ndarray 다루기 (1)\n",
    "  - (numpy 기본) 문제 2. ndarray 다루기 (2)\n",
    "  - (numpy 선형대수) 문제 3. 선형방정식 풀기(해 구하기)\n",
    "* pandas 기초\n",
    "  - (pandas 기본) 문제 1. DataFrame 다루기 (1)\n",
    "  - (pandas 기본) 문제 2. DataFrame 다루기 (2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  numpy 기초"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### (numpy 기본) 문제 1. ndarray 다루기 (1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 다음의 데이터를 사용하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "2 3 5 6 7 10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a) 데이터 벡터 x를 만드시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) 각 데이터의 제곱으로 구성된 벡터 x2를 만드시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### c) 각 데이터의 제곱의 합을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### d) 각 데이터에서 2를 뺀 값을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### e) 최대값과 최소값을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### f) 5보다 큰 값들로만 구성된 데이터 벡터 x_up을 만드시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### g) 벡터 x의 길이를 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### h) x'x를 구하시오 (x'는 x의 전치)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### i) xx'를 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### j) 벡터 x와 x2를 열결합(column bind)하여 xc에 저장하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### k) 벡터 x와 x2를 행결합(row bind)하여 xr에 저장하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### (numpy 기본) 문제 2. ndarray 다루기 (2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a ) 표준정규분포를 따르는 난수 100개를 가진 배열 x를 만드시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) x에서 값이 0.2 보다 큰 원소들을 골라내시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### (numpy 선형대수) 문제 3. 선형방정식 풀기(해 구하기)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 다음과 같은 방정식이 있다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "3x + 6y - 5z = 12\n",
    "x - 3y + 2z = -2\n",
    "5x - y + 4z = 10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a) 위 식을 numpy를 이용해서 Ax=B 형태로 나타내시오 (A와 B만 생성)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) A의 역행렬을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### c) 방정식의 해 벡터 x를 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### pandas 기초"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### (pandas 기본) 문제 1. DataFrame 다루기 (1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "   | numbers |\n",
    "----- | ------ \n",
    "a  | 10 \n",
    "b  | 20 \n",
    "c  | 30 \n",
    "d  | 40 \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a) DataFrame으로 위와 같은 자료를 만드시오. 컬럼 이름은 numbers, 로우 네임은 a~e, 값은 10~40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) c 로우의 값을 가져오시오."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### c) a, d 로우들의 값을 가져오시오."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### d) numbers의 합을 구하시오."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### e) numbers의 값들을 각각 제곱하시오 (vectorized operations 표헌으로 예] 2*v )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 이런 결과가 나와야 함.\n",
    "\n",
    "  | numbers |\n",
    "----- | ------ \n",
    "a  | 100 \n",
    "b  | 400 \n",
    "c  | 900 \n",
    "d  | 1600 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### f) numbers의 값들을 각각 제곱하시오(apply 메서드 사용해서)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### f) numbers의 값들을 각각 제곱하시오(apply 메서드에, 람다 함수도 사용해서)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### g) floats라는 이름의 칼럼을 추가하시오. 값은 1.5, 2.5, 3.5, 4.5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 이런 결과가 나와야 함.\n",
    "\n",
    "| numbers | floats\n",
    "----- | ------ | ------\n",
    "a  | 10 | 1.5\n",
    "b  | 20 | 2.5\n",
    "c  | 30 | 3.5\n",
    "d  | 40 | 4.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### h) names라는 이름의 다음과 같은 칼럼을 위의 결과에 또 추가하시오. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " | names | \n",
    " ----- | ------\n",
    " d  | Guido \n",
    " a  | Felix\n",
    " b  | Francesc\n",
    " c  | Yves"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### i) 다음과 같은 정보를 가지는 로우(행)를 위의 결과에 추가하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "index:z, numbers: 100, floats: 5.75, names: Henry"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### j) squares 라는 이름의 칼럼을 위의 결과에 추가하시오. 그런데 squares는 인덱스값이 짝이 맞지 않으므로 join 메서드를 사용하시오(기본옵션으로)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "  | squares |\n",
    "----- | ------ \n",
    "a  | 1\n",
    "b  | 4\n",
    "c  | 9\n",
    "d  | 16\n",
    "y  | 25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### k) j와 동일하나 join 메서드의 옵션을 'outer'로 바꿔서 수행해보시오."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### l) 위의 결과로 나온 자료에서 numbers 칼럼과 squares 칼럼에 대해, 각각 평균을 구하시오. 다음과 같은 결과가 나와야 함. (mean 메서드 사용, column-wise 계산)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "numbers 40\n",
    "squares 11"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### m) numbers와 squares 칼럼에 대해, 각각 표준편차를 구하시오 (std 메서드 사용, column-wise 계산)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### (pandas 기본) 문제 2. DataFrame 다루기 (2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a) 표준정규분포를 따르는 9 X 4 형태의 DataFrame을 생성하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) a에서 생성한 DataFrame의 칼럼 이름을 - No1, No2, No2, No4로 지정하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### e) 위에서 생성된 자료에, 시간 관련 인덱싱을 하기 위해서는 DataTime 자료형을 생성해서 로우 인덱스에 넣어주는 방법이 있다.  아래코드를 실행하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# import pandas as pd 라는 가정하에.\n",
    "dates = pd.date_range(‘2015-1-1’, periods=9, freq=‘M’)\n",
    "df.index = dates # a와 b를 거쳐서 만들어진 DataFrame 인스턴스의 변수명이 df라고 가정.\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### f) 각 컬럼의 평균을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### f) 5월부터 7월까지의, 각 컬럼의 평균을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 응용"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 응용문제 1 - pandas의 DataFrame을 이용한 엑셀파일 분석\n",
    "* 응용문제 2 - pandas의 DataFrame을 이용한 주식 데이터 분석 [3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 응용문제 1 - pandas의 DataFrame을 이용한 엑셀파일 분석"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* person.xls 파일을 pandas로 읽어서 DataFrame 자료로 받는다.\n",
    "* (힌트, 엑셀에서 열어서 csv 포맷으로 바꾸면 훨씬 쉬워진다)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 1) score의 평균을 구하기"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 2) 남,녀별 score 평균 구하기"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 3) 각 email의 값은 비워져있다. 채워넣어보자. 이메일은 '아이디@회사이름.com' 규칙을 따른다. 예를들어 id가 user1이고 회사가 naver이면 그 사람의 email은 user1@naver.com 이다."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 응용문제 2 - pandas의 DataFrame을 이용한 주식 데이터 분석"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### 야후 파이낸스 API를 이용해서 특정 주식의 정보를 받아오는 코드는 아래와 같다. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex: 3873 entries, 2000-01-03 00:00:00 to 2015-03-12 00:00:00\n",
      "Data columns (total 6 columns):\n",
      "Open         3873 non-null float64\n",
      "High         3873 non-null float64\n",
      "Low          3873 non-null float64\n",
      "Close        3873 non-null float64\n",
      "Volume       3873 non-null int64\n",
      "Adj Close    3873 non-null float64\n",
      "dtypes: float64(5), int64(1)\n",
      "memory usage: 211.8 KB\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import pandas.io.data as web\n",
    "\n",
    "DAX = web.DataReader(name='^GDAXI', data_source='yahoo', start='2000-1-1')\n",
    "DAX.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Volume</th>\n",
       "      <th>Adj Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2000-01-03</th>\n",
       "      <td> 6961.72</td>\n",
       "      <td> 7159.33</td>\n",
       "      <td> 6720.87</td>\n",
       "      <td> 6750.76</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6750.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-04</th>\n",
       "      <td> 6747.24</td>\n",
       "      <td> 6755.36</td>\n",
       "      <td> 6510.46</td>\n",
       "      <td> 6586.95</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6586.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-05</th>\n",
       "      <td> 6585.85</td>\n",
       "      <td> 6585.85</td>\n",
       "      <td> 6388.91</td>\n",
       "      <td> 6502.07</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6502.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-06</th>\n",
       "      <td> 6501.45</td>\n",
       "      <td> 6539.31</td>\n",
       "      <td> 6402.63</td>\n",
       "      <td> 6474.92</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6474.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000-01-07</th>\n",
       "      <td> 6489.94</td>\n",
       "      <td> 6791.53</td>\n",
       "      <td> 6470.14</td>\n",
       "      <td> 6780.96</td>\n",
       "      <td> 0</td>\n",
       "      <td> 6780.96</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               Open     High      Low    Close  Volume  Adj Close\n",
       "Date                                                             \n",
       "2000-01-03  6961.72  7159.33  6720.87  6750.76       0    6750.76\n",
       "2000-01-04  6747.24  6755.36  6510.46  6586.95       0    6586.95\n",
       "2000-01-05  6585.85  6585.85  6388.91  6502.07       0    6502.07\n",
       "2000-01-06  6501.45  6539.31  6402.63  6474.92       0    6474.92\n",
       "2000-01-07  6489.94  6791.53  6470.14  6780.96       0    6780.96"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DAX.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Volume</th>\n",
       "      <th>Adj Close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td> 11513.89</td>\n",
       "      <td> 11600.37</td>\n",
       "      <td> 11495.20</td>\n",
       "      <td> 11550.97</td>\n",
       "      <td>         0</td>\n",
       "      <td> 11550.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-09</th>\n",
       "      <td> 11510.35</td>\n",
       "      <td> 11586.94</td>\n",
       "      <td> 11461.86</td>\n",
       "      <td> 11582.11</td>\n",
       "      <td>         0</td>\n",
       "      <td> 11582.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-10</th>\n",
       "      <td> 11555.97</td>\n",
       "      <td> 11577.75</td>\n",
       "      <td> 11402.67</td>\n",
       "      <td> 11500.38</td>\n",
       "      <td>         0</td>\n",
       "      <td> 11500.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-11</th>\n",
       "      <td> 11531.55</td>\n",
       "      <td> 11822.53</td>\n",
       "      <td> 11531.55</td>\n",
       "      <td> 11805.99</td>\n",
       "      <td>         0</td>\n",
       "      <td> 11805.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-12</th>\n",
       "      <td> 11795.91</td>\n",
       "      <td> 11830.14</td>\n",
       "      <td> 11754.90</td>\n",
       "      <td> 11799.39</td>\n",
       "      <td> 116256000</td>\n",
       "      <td> 11799.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                Open      High       Low     Close     Volume  Adj Close\n",
       "Date                                                                    \n",
       "2015-03-06  11513.89  11600.37  11495.20  11550.97          0   11550.97\n",
       "2015-03-09  11510.35  11586.94  11461.86  11582.11          0   11582.11\n",
       "2015-03-10  11555.97  11577.75  11402.67  11500.38          0   11500.38\n",
       "2015-03-11  11531.55  11822.53  11531.55  11805.99          0   11805.99\n",
       "2015-03-12  11795.91  11830.14  11754.90  11799.39  116256000   11799.39"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DAX.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### a) 위의 코드를 실행해서 값을 가져오시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### b) High와 Low의 차이를 계산해서 Diff라는 이름의 칼럼을 만들어 그 결과를 반영하시오."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### c) 2015년의 Open, High, Low, Close의 각 평균을 구하시오"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# input yuour code"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 참고자료 \n",
    "\n",
    " * [1] 데이터/수치 분석을 위한 파이썬 라이브러리 SciPy와 NumPy - http://www.hanbit.co.kr/ebook/look.html?isbn=9788968486135\n",
    " * [2] 파이썬 라이브러리를 활용한 데이터 분석 - http://www.hanbit.co.kr/book/look.html?isbn=978-89-6848-047-8\n",
    " * [3] Python for Finance - http://shop.oreilly.com/product/0636920032441.do"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}