Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "----------\n",
- "## *1. セル値の読み込みと書き込みを使う場面*"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# 3つのデータを一括で貼り付けます。\n",
- "for i , title in enumerate(title_names) :\n",
- " # シートの作成\n",
- " report_wb.create_sheet(title)\n",
- " # シートの読み込み\n",
- " report_ws = report_wb.get_sheet_by_name(title)\n",
- " \n",
- " # セル値の読み込みと書き込み\n",
- " for column_num in range(1,reports[i].max_column) : \n",
- " for row_num in range(1,reports[i].max_row) :\n",
- " report_ws.cell(row=row_num,column=column_num).value = reports[i].cell(row=row_num,column=column_num).value\n",
- " report_wb.save('report.xlsx')"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "----------\n",
- "## 2. セルの取得\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "# 今回はタイタニックデータを用いていきます。\n",
- "# タイタニックデータはCSV形式なので、一旦Excel形式に変換をします。\n",
- "import pandas as pd\n",
- "df = pd.read_csv('/Users/yanomekeita/dhu/train.csv')\n",
- "df.to_excel('train.xlsx',sheet_name = 'titanic_data')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 11,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'Survived'"
- ]
- },
- "execution_count": 11,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Excelファイル名を変数に格納します。\n",
- "excel_file = '/Users/yanomekeita/dhu/train.xlsx'\n",
- "\n",
- "# openpyxlライブラリとExcelファイルを起動します。\n",
- "import openpyxl as px\n",
- "wb = px.load_workbook(excel_file)\n",
- "\n",
- "# アクティブシートを読み取ります。\n",
- "ws = wb.active"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "'書き込みテスト'"
- ]
- },
- "execution_count": 14,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# セル値の取得ver1\n",
- "ws['C1'].value\n",
- "\n",
- "# セル値の取得ver2\n",
- "ws.cell(row= 1,column = 1).value"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "----------\n",
- "## 3. 複数セルの取得"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "書き込みテスト\n",
- "PassengerId\n",
- "Survived\n",
- "Pclass\n",
- "Name\n",
- "Sex\n",
- "Age\n",
- "SibSp\n",
- "Parch\n",
- "Ticket\n",
- "Fare\n",
- "Cabin\n"
- ]
- }
- ],
- "source": [
- "# train.xlsxの1行目(横方向)の全ての値を取得してみましょう!\n",
- "\n",
- "\n",
- "# まずはtrain.xlsxファイルの列数が何個なのかを算出してみましょう。\n",
- "ws.max_column\n",
- "\n",
- "\n",
- "# それでは、max_columnを用いて複数セルの取得を実行していきます。\n",
- "for column_num in range(1, ws.max_column) :\n",
- " print(ws.cell(row = 1 , column = column_num).value)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 26,
- "metadata": {},
- "outputs": [],
- "source": [
- "# 次に1行の全ての値を取得していきます。\n",
- "for row_num in range(1, ws.max_row) : \n",
- " ws.cell(row = row_num,column = 1).value"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 27,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# 全データを一括で取得します。\n",
- "for column_num in range(1, ws.max_column) :\n",
- " for row_num in range(1, ws.max_row) :\n",
- " ws.cell(row = row_num , column = column_num)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "----------\n",
- "## 4. セルの書き込み\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# 先ほどのtrain.xlsxを使用していきます。\n",
- "wb = px.load_workbook(excel_file)\n",
- "ws = wb.active\n",
- "\n",
- "# アクティブシートのセルに値を書き込んでいきます。\n",
- "ws['A1'].value = '書き込み'\n",
- "\n",
- "# Excelを保存します。\n",
- "wb.save(excel_file)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "----------\n",
- "## 5. 【小テスト1】シートのコピー\n",
- "**【内容】**\n",
- "\n",
- "別シートを作成し、train.xlsxのデータを丸々コピペしてみましょう。\n",
- "\n",
- "\n",
- "**【手順】**\n",
- "1. train.xlsxファイルの中に別シートを作成します。\n",
- "2. train.xlsxのシートのセル値を全て取得します。\n",
- "3. 新たに作成したシートのセルに、train.xlsxのセル値を書き込みます。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 29,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# 先ほどのtrain.xlsxを使用していきます。\n",
- "wb = px.load_workbook(excel_file)\n",
- "ws = wb.active"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 30,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# シートの作成\n",
- "copy_ws = wb.create_sheet('copy_titanic_data')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 32,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# train.xlsxにあるデータを取得していきます。\n",
- "for column_num in range(1, ws.max_column):\n",
- " for row_num in range(1, ws.max_row):\n",
- " # セル値を新しく作成したシートに貼り付けます。\n",
- " copy_ws.cell(row = row_num , column = column_num).value = ws.cell(row = row_num , column = column_num).value\n",
- "\n",
- "# Excelファイルを保存して終了です。\n",
- "wb.save(excel_file)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "------------------------------------------------------------------------\n",
- "## 6.【小テスト2】条件別にExcelシートを作成する\n",
- "**【内容】**\n",
- "Pclass1の人だけを抽出し、新規シートを作成しそこに保存をしてみましょう。\n",
- "\n",
- "**【手順】**\n",
- "1. データフレームで、データを必要な形に変換します。\n",
- "2. 新たなシートを作成します。\n",
- "3. 新規作成したシートに、変換したデータをExcelに貼り付けます。"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 35,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style>\n",
- " .dataframe thead tr:only-child th {\n",
- " text-align: right;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: left;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>PassengerId</th>\n",
- " <th>Survived</th>\n",
- " <th>Pclass</th>\n",
- " <th>Name</th>\n",
- " <th>Sex</th>\n",
- " <th>Age</th>\n",
- " <th>SibSp</th>\n",
- " <th>Parch</th>\n",
- " <th>Ticket</th>\n",
- " <th>Fare</th>\n",
- " <th>Cabin</th>\n",
- " <th>Embarked</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>2</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
- " <td>female</td>\n",
- " <td>38.0</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>PC 17599</td>\n",
- " <td>71.2833</td>\n",
- " <td>C85</td>\n",
- " <td>C</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>4</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
- " <td>female</td>\n",
- " <td>35.0</td>\n",
- " <td>1</td>\n",
- " <td>0</td>\n",
- " <td>113803</td>\n",
- " <td>53.1000</td>\n",
- " <td>C123</td>\n",
- " <td>S</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>7</td>\n",
- " <td>0</td>\n",
- " <td>1</td>\n",
- " <td>McCarthy, Mr. Timothy J</td>\n",
- " <td>male</td>\n",
- " <td>54.0</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>17463</td>\n",
- " <td>51.8625</td>\n",
- " <td>E46</td>\n",
- " <td>S</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>12</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>Bonnell, Miss. Elizabeth</td>\n",
- " <td>female</td>\n",
- " <td>58.0</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>113783</td>\n",
- " <td>26.5500</td>\n",
- " <td>C103</td>\n",
- " <td>S</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>23</th>\n",
- " <td>24</td>\n",
- " <td>1</td>\n",
- " <td>1</td>\n",
- " <td>Sloper, Mr. William Thompson</td>\n",
- " <td>male</td>\n",
- " <td>28.0</td>\n",
- " <td>0</td>\n",
- " <td>0</td>\n",
- " <td>113788</td>\n",
- " <td>35.5000</td>\n",
- " <td>A6</td>\n",
- " <td>S</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " PassengerId Survived Pclass \\\n",
- "1 2 1 1 \n",
- "3 4 1 1 \n",
- "6 7 0 1 \n",
- "11 12 1 1 \n",
- "23 24 1 1 \n",
- "\n",
- " Name Sex Age SibSp \\\n",
- "1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n",
- "3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n",
- "6 McCarthy, Mr. Timothy J male 54.0 0 \n",
- "11 Bonnell, Miss. Elizabeth female 58.0 0 \n",
- "23 Sloper, Mr. William Thompson male 28.0 0 \n",
- "\n",
- " Parch Ticket Fare Cabin Embarked \n",
- "1 0 PC 17599 71.2833 C85 C \n",
- "3 0 113803 53.1000 C123 S \n",
- "6 0 17463 51.8625 E46 S \n",
- "11 0 113783 26.5500 C103 S \n",
- "23 0 113788 35.5000 A6 S "
- ]
- },
- "execution_count": 35,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Pandasとデータのインポート\n",
- "import pandas as pd\n",
- "df = pd.read_csv('/Users/yanomekeita/dhu/train.csv')\n",
- "\n",
- "# データフレームで、Pclass1の人だけに加工をします。\n",
- "df = df[df.Pclass ==1]\n",
- "df.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### *変換したデータフレームをExcelファイルに書き込んでいきます。*"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 37,
- "metadata": {},
- "outputs": [],
- "source": [
- "# ライブラリのインポート\n",
- "from openpyxl.utils.dataframe import dataframe_to_rows\n",
- "\n",
- "# Excelファイルの読みこみ\n",
- "wb = px.load_workbook(excel_file)\n",
- "\n",
- "# 新たなシートを作成し、シートの読み込みを行います。\n",
- "ws = wb.create_sheet('Pclass1')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 42,
- "metadata": {},
- "outputs": [],
- "source": [
- "# appendで、セルに書き込みをすることが可能です。\n",
- "ws.append(['test','です'])\n",
- "wb.save(excel_file)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 44,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "[None, 'PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp', 'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked']\n",
- "[1, 2, 1, 1, 'Cumings, Mrs. John Bradley (Florence Briggs Thayer)', 'female', 38.0, 1, 0, 'PC 17599', 71.2833, 'C85', 'C']\n",
- "[3, 4, 1, 1, 'Futrelle, Mrs. Jacques Heath (Lily May Peel)', 'female', 35.0, 1, 0, '113803', 53.1, 'C123', 'S']\n",
- "[6, 7, 0, 1, 'McCarthy, Mr. Timothy J', 'male', 54.0, 0, 0, '17463', 51.8625, 'E46', 'S']\n",
- "[11, 12, 1, 1, 'Bonnell, Miss. Elizabeth', 'female', 58.0, 0, 0, '113783', 26.55, 'C103', 'S']\n",
- "[23, 24, 1, 1, 'Sloper, Mr. William Thompson', 'male', 28.0, 0, 0, '113788', 35.5, 'A6', 'S']\n",
- "[27, 28, 0, 1, 'Fortune, Mr. Charles Alexander', 'male', 19.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
- "[30, 31, 0, 1, 'Uruchurtu, Don. Manuel E', 'male', 40.0, 0, 0, 'PC 17601', 27.7208, nan, 'C']\n",
- "[31, 32, 1, 1, 'Spencer, Mrs. William Augustus (Marie Eugenie)', 'female', nan, 1, 0, 'PC 17569', 146.5208, 'B78', 'C']\n",
- "[34, 35, 0, 1, 'Meyer, Mr. Edgar Joseph', 'male', 28.0, 1, 0, 'PC 17604', 82.1708, nan, 'C']\n",
- "[35, 36, 0, 1, 'Holverson, Mr. Alexander Oskar', 'male', 42.0, 1, 0, '113789', 52.0, nan, 'S']\n",
- "[52, 53, 1, 1, 'Harper, Mrs. Henry Sleeper (Myna Haxtun)', 'female', 49.0, 1, 0, 'PC 17572', 76.7292, 'D33', 'C']\n",
- "[54, 55, 0, 1, 'Ostby, Mr. Engelhart Cornelius', 'male', 65.0, 0, 1, '113509', 61.9792, 'B30', 'C']\n",
- "[55, 56, 1, 1, 'Woolner, Mr. Hugh', 'male', nan, 0, 0, '19947', 35.5, 'C52', 'S']\n",
- "[61, 62, 1, 1, 'Icard, Miss. Amelie', 'female', 38.0, 0, 0, '113572', 80.0, 'B28', nan]\n",
- "[62, 63, 0, 1, 'Harris, Mr. Henry Birkhardt', 'male', 45.0, 1, 0, '36973', 83.475, 'C83', 'S']\n",
- "[64, 65, 0, 1, 'Stewart, Mr. Albert A', 'male', nan, 0, 0, 'PC 17605', 27.7208, nan, 'C']\n",
- "[83, 84, 0, 1, 'Carrau, Mr. Francisco M', 'male', 28.0, 0, 0, '113059', 47.1, nan, 'S']\n",
- "[88, 89, 1, 1, 'Fortune, Miss. Mabel Helen', 'female', 23.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
- "[92, 93, 0, 1, 'Chaffee, Mr. Herbert Fuller', 'male', 46.0, 1, 0, 'W.E.P. 5734', 61.175, 'E31', 'S']\n",
- "[96, 97, 0, 1, 'Goldschmidt, Mr. George B', 'male', 71.0, 0, 0, 'PC 17754', 34.6542, 'A5', 'C']\n",
- "[97, 98, 1, 1, 'Greenfield, Mr. William Bertram', 'male', 23.0, 0, 1, 'PC 17759', 63.3583, 'D10 D12', 'C']\n",
- "[102, 103, 0, 1, 'White, Mr. Richard Frasar', 'male', 21.0, 0, 1, '35281', 77.2875, 'D26', 'S']\n",
- "[110, 111, 0, 1, 'Porter, Mr. Walter Chamberlain', 'male', 47.0, 0, 0, '110465', 52.0, 'C110', 'S']\n",
- "[118, 119, 0, 1, 'Baxter, Mr. Quigg Edmond', 'male', 24.0, 0, 1, 'PC 17558', 247.5208, 'B58 B60', 'C']\n",
- "[124, 125, 0, 1, 'White, Mr. Percival Wayland', 'male', 54.0, 0, 1, '35281', 77.2875, 'D26', 'S']\n",
- "[136, 137, 1, 1, 'Newsom, Miss. Helen Monypeny', 'female', 19.0, 0, 2, '11752', 26.2833, 'D47', 'S']\n",
- "[137, 138, 0, 1, 'Futrelle, Mr. Jacques Heath', 'male', 37.0, 1, 0, '113803', 53.1, 'C123', 'S']\n",
- "[139, 140, 0, 1, 'Giglio, Mr. Victor', 'male', 24.0, 0, 0, 'PC 17593', 79.2, 'B86', 'C']\n",
- "[151, 152, 1, 1, 'Pears, Mrs. Thomas (Edith Wearne)', 'female', 22.0, 1, 0, '113776', 66.6, 'C2', 'S']\n",
- "[155, 156, 0, 1, 'Williams, Mr. Charles Duane', 'male', 51.0, 0, 1, 'PC 17597', 61.3792, nan, 'C']\n",
- "[166, 167, 1, 1, 'Chibnall, Mrs. (Edith Martha Bowerman)', 'female', nan, 0, 1, '113505', 55.0, 'E33', 'S']\n",
- "[168, 169, 0, 1, 'Baumann, Mr. John D', 'male', nan, 0, 0, 'PC 17318', 25.925, nan, 'S']\n",
- "[170, 171, 0, 1, 'Van der hoef, Mr. Wyckoff', 'male', 61.0, 0, 0, '111240', 33.5, 'B19', 'S']\n",
- "[174, 175, 0, 1, 'Smith, Mr. James Clinch', 'male', 56.0, 0, 0, '17764', 30.6958, 'A7', 'C']\n",
- "[177, 178, 0, 1, 'Isham, Miss. Ann Elizabeth', 'female', 50.0, 0, 0, 'PC 17595', 28.7125, 'C49', 'C']\n",
- "[185, 186, 0, 1, 'Rood, Mr. Hugh Roscoe', 'male', nan, 0, 0, '113767', 50.0, 'A32', 'S']\n",
- "[187, 188, 1, 1, 'Romaine, Mr. Charles Hallace (\"Mr C Rolmane\")', 'male', 45.0, 0, 0, '111428', 26.55, nan, 'S']\n",
- "[194, 195, 1, 1, 'Brown, Mrs. James Joseph (Margaret Tobin)', 'female', 44.0, 0, 0, 'PC 17610', 27.7208, 'B4', 'C']\n",
- "[195, 196, 1, 1, 'Lurette, Miss. Elise', 'female', 58.0, 0, 0, 'PC 17569', 146.5208, 'B80', 'C']\n",
- "[209, 210, 1, 1, 'Blank, Mr. Henry', 'male', 40.0, 0, 0, '112277', 31.0, 'A31', 'C']\n",
- "[215, 216, 1, 1, 'Newell, Miss. Madeleine', 'female', 31.0, 1, 0, '35273', 113.275, 'D36', 'C']\n",
- "[218, 219, 1, 1, 'Bazzani, Miss. Albina', 'female', 32.0, 0, 0, '11813', 76.2917, 'D15', 'C']\n",
- "[224, 225, 1, 1, 'Hoyt, Mr. Frederick Maxfield', 'male', 38.0, 1, 0, '19943', 90.0, 'C93', 'S']\n",
- "[230, 231, 1, 1, 'Harris, Mrs. Henry Birkhardt (Irene Wallach)', 'female', 35.0, 1, 0, '36973', 83.475, 'C83', 'S']\n",
- "[245, 246, 0, 1, 'Minahan, Dr. William Edward', 'male', 44.0, 2, 0, '19928', 90.0, 'C78', 'Q']\n",
- "[248, 249, 1, 1, 'Beckwith, Mr. Richard Leonard', 'male', 37.0, 1, 1, '11751', 52.5542, 'D35', 'S']\n",
- "[252, 253, 0, 1, 'Stead, Mr. William Thomas', 'male', 62.0, 0, 0, '113514', 26.55, 'C87', 'S']\n",
- "[256, 257, 1, 1, 'Thorne, Mrs. Gertrude Maybelle', 'female', nan, 0, 0, 'PC 17585', 79.2, nan, 'C']\n",
- "[257, 258, 1, 1, 'Cherry, Miss. Gladys', 'female', 30.0, 0, 0, '110152', 86.5, 'B77', 'S']\n",
- "[258, 259, 1, 1, 'Ward, Miss. Anna', 'female', 35.0, 0, 0, 'PC 17755', 512.3292, nan, 'C']\n",
- "[262, 263, 0, 1, 'Taussig, Mr. Emil', 'male', 52.0, 1, 1, '110413', 79.65, 'E67', 'S']\n",
- "[263, 264, 0, 1, 'Harrison, Mr. William', 'male', 40.0, 0, 0, '112059', 0.0, 'B94', 'S']\n",
- "[268, 269, 1, 1, 'Graham, Mrs. William Thompson (Edith Junkins)', 'female', 58.0, 0, 1, 'PC 17582', 153.4625, 'C125', 'S']\n",
- "[269, 270, 1, 1, 'Bissette, Miss. Amelia', 'female', 35.0, 0, 0, 'PC 17760', 135.6333, 'C99', 'S']\n",
- "[270, 271, 0, 1, 'Cairns, Mr. Alexander', 'male', nan, 0, 0, '113798', 31.0, nan, 'S']\n",
- "[273, 274, 0, 1, 'Natsch, Mr. Charles H', 'male', 37.0, 0, 1, 'PC 17596', 29.7, 'C118', 'C']\n",
- "[275, 276, 1, 1, 'Andrews, Miss. Kornelia Theodosia', 'female', 63.0, 1, 0, '13502', 77.9583, 'D7', 'S']\n",
- "[284, 285, 0, 1, 'Smith, Mr. Richard William', 'male', nan, 0, 0, '113056', 26.0, 'A19', 'S']\n",
- "[290, 291, 1, 1, 'Barber, Miss. Ellen \"Nellie\"', 'female', 26.0, 0, 0, '19877', 78.85, nan, 'S']\n",
- "[291, 292, 1, 1, 'Bishop, Mrs. Dickinson H (Helen Walton)', 'female', 19.0, 1, 0, '11967', 91.0792, 'B49', 'C']\n",
- "[295, 296, 0, 1, 'Lewy, Mr. Ervin G', 'male', nan, 0, 0, 'PC 17612', 27.7208, nan, 'C']\n",
- "[297, 298, 0, 1, 'Allison, Miss. Helen Loraine', 'female', 2.0, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
- "[298, 299, 1, 1, 'Saalfeld, Mr. Adolphe', 'male', nan, 0, 0, '19988', 30.5, 'C106', 'S']\n",
- "[299, 300, 1, 1, 'Baxter, Mrs. James (Helene DeLaudeniere Chaput)', 'female', 50.0, 0, 1, 'PC 17558', 247.5208, 'B58 B60', 'C']\n",
- "[305, 306, 1, 1, 'Allison, Master. Hudson Trevor', 'male', 0.92, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
- "[306, 307, 1, 1, 'Fleming, Miss. Margaret', 'female', nan, 0, 0, '17421', 110.8833, nan, 'C']\n",
- "[307, 308, 1, 1, 'Penasco y Castellana, Mrs. Victor de Satode (Maria Josefa Perez de Soto y Vallejo)', 'female', 17.0, 1, 0, 'PC 17758', 108.9, 'C65', 'C']\n",
- "[309, 310, 1, 1, 'Francatelli, Miss. Laura Mabel', 'female', 30.0, 0, 0, 'PC 17485', 56.9292, 'E36', 'C']\n",
- "[310, 311, 1, 1, 'Hays, Miss. Margaret Bechstein', 'female', 24.0, 0, 0, '11767', 83.1583, 'C54', 'C']\n",
- "[311, 312, 1, 1, 'Ryerson, Miss. Emily Borie', 'female', 18.0, 2, 2, 'PC 17608', 262.375, 'B57 B59 B63 B66', 'C']\n",
- "[318, 319, 1, 1, 'Wick, Miss. Mary Natalie', 'female', 31.0, 0, 2, '36928', 164.8667, 'C7', 'S']\n",
- "[319, 320, 1, 1, 'Spedden, Mrs. Frederic Oakley (Margaretta Corning Stone)', 'female', 40.0, 1, 1, '16966', 134.5, 'E34', 'C']\n",
- "[325, 326, 1, 1, 'Young, Miss. Marie Grice', 'female', 36.0, 0, 0, 'PC 17760', 135.6333, 'C32', 'C']\n",
- "[329, 330, 1, 1, 'Hippach, Miss. Jean Gertrude', 'female', 16.0, 0, 1, '111361', 57.9792, 'B18', 'C']\n",
- "[331, 332, 0, 1, 'Partner, Mr. Austen', 'male', 45.5, 0, 0, '113043', 28.5, 'C124', 'S']\n",
- "[332, 333, 0, 1, 'Graham, Mr. George Edward', 'male', 38.0, 0, 1, 'PC 17582', 153.4625, 'C91', 'S']\n",
- "[334, 335, 1, 1, 'Frauenthal, Mrs. Henry William (Clara Heinsheimer)', 'female', nan, 1, 0, 'PC 17611', 133.65, nan, 'S']\n",
- "[336, 337, 0, 1, 'Pears, Mr. Thomas Clinton', 'male', 29.0, 1, 0, '113776', 66.6, 'C2', 'S']\n",
- "[337, 338, 1, 1, 'Burns, Miss. Elizabeth Margaret', 'female', 41.0, 0, 0, '16966', 134.5, 'E40', 'C']\n",
- "[339, 340, 0, 1, 'Blackwell, Mr. Stephen Weart', 'male', 45.0, 0, 0, '113784', 35.5, 'T', 'S']\n",
- "[341, 342, 1, 1, 'Fortune, Miss. Alice Elizabeth', 'female', 24.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
- "[351, 352, 0, 1, 'Williams-Lambert, Mr. Fletcher Fellows', 'male', nan, 0, 0, '113510', 35.0, 'C128', 'S']\n",
- "[356, 357, 1, 1, 'Bowerman, Miss. Elsie Edith', 'female', 22.0, 0, 1, '113505', 55.0, 'E33', 'S']\n",
- "[366, 367, 1, 1, 'Warren, Mrs. Frank Manley (Anna Sophia Atkinson)', 'female', 60.0, 1, 0, '110813', 75.25, 'D37', 'C']\n",
- "[369, 370, 1, 1, 'Aubart, Mme. Leontine Pauline', 'female', 24.0, 0, 0, 'PC 17477', 69.3, 'B35', 'C']\n",
- "[370, 371, 1, 1, 'Harder, Mr. George Achilles', 'male', 25.0, 1, 0, '11765', 55.4417, 'E50', 'C']\n",
- "[373, 374, 0, 1, 'Ringhini, Mr. Sante', 'male', 22.0, 0, 0, 'PC 17760', 135.6333, nan, 'C']\n",
- "[375, 376, 1, 1, 'Meyer, Mrs. Edgar Joseph (Leila Saks)', 'female', nan, 1, 0, 'PC 17604', 82.1708, nan, 'C']\n",
- "[377, 378, 0, 1, 'Widener, Mr. Harry Elkins', 'male', 27.0, 0, 2, '113503', 211.5, 'C82', 'C']\n",
- "[380, 381, 1, 1, 'Bidois, Miss. Rosalie', 'female', 42.0, 0, 0, 'PC 17757', 227.525, nan, 'C']\n",
- "[383, 384, 1, 1, 'Holverson, Mrs. Alexander Oskar (Mary Aline Towner)', 'female', 35.0, 1, 0, '113789', 52.0, nan, 'S']\n",
- "[390, 391, 1, 1, 'Carter, Mr. William Ernest', 'male', 36.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
- "[393, 394, 1, 1, 'Newell, Miss. Marjorie', 'female', 23.0, 1, 0, '35273', 113.275, 'D36', 'C']\n",
- "[412, 413, 1, 1, 'Minahan, Miss. Daisy E', 'female', 33.0, 1, 0, '19928', 90.0, 'C78', 'Q']\n",
- "[430, 431, 1, 1, 'Bjornstrom-Steffansson, Mr. Mauritz Hakan', 'male', 28.0, 0, 0, '110564', 26.55, 'C52', 'S']\n",
- "[434, 435, 0, 1, 'Silvey, Mr. William Baird', 'male', 50.0, 1, 0, '13507', 55.9, 'E44', 'S']\n",
- "[435, 436, 1, 1, 'Carter, Miss. Lucile Polk', 'female', 14.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
- "[438, 439, 0, 1, 'Fortune, Mr. Mark', 'male', 64.0, 1, 4, '19950', 263.0, 'C23 C25 C27', 'S']\n",
- "[445, 446, 1, 1, 'Dodge, Master. Washington', 'male', 4.0, 0, 2, '33638', 81.8583, 'A34', 'S']\n",
- "[447, 448, 1, 1, 'Seward, Mr. Frederic Kimber', 'male', 34.0, 0, 0, '113794', 26.55, nan, 'S']\n",
- "[449, 450, 1, 1, 'Peuchen, Major. Arthur Godfrey', 'male', 52.0, 0, 0, '113786', 30.5, 'C104', 'S']\n",
- "[452, 453, 0, 1, 'Foreman, Mr. Benjamin Laventall', 'male', 30.0, 0, 0, '113051', 27.75, 'C111', 'C']\n",
- "[453, 454, 1, 1, 'Goldenberg, Mr. Samuel L', 'male', 49.0, 1, 0, '17453', 89.1042, 'C92', 'C']\n",
- "[456, 457, 0, 1, 'Millet, Mr. Francis Davis', 'male', 65.0, 0, 0, '13509', 26.55, 'E38', 'S']\n",
- "[457, 458, 1, 1, 'Kenyon, Mrs. Frederick R (Marion)', 'female', nan, 1, 0, '17464', 51.8625, 'D21', 'S']\n",
- "[460, 461, 1, 1, 'Anderson, Mr. Harry', 'male', 48.0, 0, 0, '19952', 26.55, 'E12', 'S']\n",
- "[462, 463, 0, 1, 'Gee, Mr. Arthur H', 'male', 47.0, 0, 0, '111320', 38.5, 'E63', 'S']\n",
- "[467, 468, 0, 1, 'Smart, Mr. John Montgomery', 'male', 56.0, 0, 0, '113792', 26.55, nan, 'S']\n",
- "[475, 476, 0, 1, 'Clifford, Mr. George Quincy', 'male', nan, 0, 0, '110465', 52.0, 'A14', 'S']\n",
- "[484, 485, 1, 1, 'Bishop, Mr. Dickinson H', 'male', 25.0, 1, 0, '11967', 91.0792, 'B49', 'C']\n",
- "[486, 487, 1, 1, 'Hoyt, Mrs. Frederick Maxfield (Jane Anne Forby)', 'female', 35.0, 1, 0, '19943', 90.0, 'C93', 'S']\n",
- "[487, 488, 0, 1, 'Kent, Mr. Edward Austin', 'male', 58.0, 0, 0, '11771', 29.7, 'B37', 'C']\n",
- "[492, 493, 0, 1, 'Molson, Mr. Harry Markland', 'male', 55.0, 0, 0, '113787', 30.5, 'C30', 'S']\n",
- "[493, 494, 0, 1, 'Artagaveytia, Mr. Ramon', 'male', 71.0, 0, 0, 'PC 17609', 49.5042, nan, 'C']\n",
- "[496, 497, 1, 1, 'Eustis, Miss. Elizabeth Mussey', 'female', 54.0, 1, 0, '36947', 78.2667, 'D20', 'C']\n",
- "[498, 499, 0, 1, 'Allison, Mrs. Hudson J C (Bessie Waldo Daniels)', 'female', 25.0, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
- "[504, 505, 1, 1, 'Maioni, Miss. Roberta', 'female', 16.0, 0, 0, '110152', 86.5, 'B79', 'S']\n",
- "[505, 506, 0, 1, 'Penasco y Castellana, Mr. Victor de Satode', 'male', 18.0, 1, 0, 'PC 17758', 108.9, 'C65', 'C']\n",
- "[507, 508, 1, 1, 'Bradley, Mr. George (\"George Arthur Brayton\")', 'male', nan, 0, 0, '111427', 26.55, nan, 'S']\n",
- "[512, 513, 1, 1, 'McGough, Mr. James Robert', 'male', 36.0, 0, 0, 'PC 17473', 26.2875, 'E25', 'S']\n",
- "[513, 514, 1, 1, 'Rothschild, Mrs. Martin (Elizabeth L. Barrett)', 'female', 54.0, 1, 0, 'PC 17603', 59.4, nan, 'C']\n",
- "[515, 516, 0, 1, 'Walker, Mr. William Anderson', 'male', 47.0, 0, 0, '36967', 34.0208, 'D46', 'S']\n",
- "[520, 521, 1, 1, 'Perreault, Miss. Anne', 'female', 30.0, 0, 0, '12749', 93.5, 'B73', 'S']\n",
- "[523, 524, 1, 1, 'Hippach, Mrs. Louis Albert (Ida Sophia Fischer)', 'female', 44.0, 0, 1, '111361', 57.9792, 'B18', 'C']\n",
- "[527, 528, 0, 1, 'Farthing, Mr. John', 'male', nan, 0, 0, 'PC 17483', 221.7792, 'C95', 'S']\n",
- "[536, 537, 0, 1, 'Butt, Major. Archibald Willingham', 'male', 45.0, 0, 0, '113050', 26.55, 'B38', 'S']\n",
- "[537, 538, 1, 1, 'LeRoy, Miss. Bertha', 'female', 30.0, 0, 0, 'PC 17761', 106.425, nan, 'C']\n",
- "[539, 540, 1, 1, 'Frolicher, Miss. Hedwig Margaritha', 'female', 22.0, 0, 2, '13568', 49.5, 'B39', 'C']\n",
- "[540, 541, 1, 1, 'Crosby, Miss. Harriet R', 'female', 36.0, 0, 2, 'WE/P 5735', 71.0, 'B22', 'S']\n",
- "[544, 545, 0, 1, 'Douglas, Mr. Walter Donald', 'male', 50.0, 1, 0, 'PC 17761', 106.425, 'C86', 'C']\n",
- "[545, 546, 0, 1, 'Nicholson, Mr. Arthur Ernest', 'male', 64.0, 0, 0, '693', 26.0, nan, 'S']\n",
- "[550, 551, 1, 1, 'Thayer, Mr. John Borland Jr', 'male', 17.0, 0, 2, '17421', 110.8833, 'C70', 'C']\n",
- "[555, 556, 0, 1, 'Wright, Mr. George', 'male', 62.0, 0, 0, '113807', 26.55, nan, 'S']\n",
- "[556, 557, 1, 1, 'Duff Gordon, Lady. (Lucille Christiana Sutherland) (\"Mrs Morgan\")', 'female', 48.0, 1, 0, '11755', 39.6, 'A16', 'C']\n",
- "[557, 558, 0, 1, 'Robbins, Mr. Victor', 'male', nan, 0, 0, 'PC 17757', 227.525, nan, 'C']\n",
- "[558, 559, 1, 1, 'Taussig, Mrs. Emil (Tillie Mandelbaum)', 'female', 39.0, 1, 1, '110413', 79.65, 'E67', 'S']\n",
- "[571, 572, 1, 1, 'Appleton, Mrs. Edward Dale (Charlotte Lamson)', 'female', 53.0, 2, 0, '11769', 51.4792, 'C101', 'S']\n",
- "[572, 573, 1, 1, 'Flynn, Mr. John Irwin (\"Irving\")', 'male', 36.0, 0, 0, 'PC 17474', 26.3875, 'E25', 'S']\n",
- "[577, 578, 1, 1, 'Silvey, Mrs. William Baird (Alice Munger)', 'female', 39.0, 1, 0, '13507', 55.9, 'E44', 'S']\n",
- "[581, 582, 1, 1, 'Thayer, Mrs. John Borland (Marian Longstreth Morris)', 'female', 39.0, 1, 1, '17421', 110.8833, 'C68', 'C']\n",
- "[583, 584, 0, 1, 'Ross, Mr. John Hugo', 'male', 36.0, 0, 0, '13049', 40.125, 'A10', 'C']\n",
- "[585, 586, 1, 1, 'Taussig, Miss. Ruth', 'female', 18.0, 0, 2, '110413', 79.65, 'E68', 'S']\n",
- "[587, 588, 1, 1, 'Frolicher-Stehli, Mr. Maxmillian', 'male', 60.0, 1, 1, '13567', 79.2, 'B41', 'C']\n",
- "[591, 592, 1, 1, 'Stephenson, Mrs. Walter Bertram (Martha Eustis)', 'female', 52.0, 1, 0, '36947', 78.2667, 'D20', 'C']\n",
- "[599, 600, 1, 1, 'Duff Gordon, Sir. Cosmo Edmund (\"Mr Morgan\")', 'male', 49.0, 1, 0, 'PC 17485', 56.9292, 'A20', 'C']\n",
- "[602, 603, 0, 1, 'Harrington, Mr. Charles H', 'male', nan, 0, 0, '113796', 42.4, nan, 'S']\n",
- "[604, 605, 1, 1, 'Homer, Mr. Harry (\"Mr E Haven\")', 'male', 35.0, 0, 0, '111426', 26.55, nan, 'C']\n",
- "[607, 608, 1, 1, 'Daniel, Mr. Robert Williams', 'male', 27.0, 0, 0, '113804', 30.5, nan, 'S']\n",
- "[609, 610, 1, 1, 'Shutes, Miss. Elizabeth W', 'female', 40.0, 0, 0, 'PC 17582', 153.4625, 'C125', 'S']\n",
- "[621, 622, 1, 1, 'Kimball, Mr. Edwin Nelson Jr', 'male', 42.0, 1, 0, '11753', 52.5542, 'D19', 'S']\n",
- "[625, 626, 0, 1, 'Sutton, Mr. Frederick', 'male', 61.0, 0, 0, '36963', 32.3208, 'D50', 'S']\n",
- "[627, 628, 1, 1, 'Longley, Miss. Gretchen Fiske', 'female', 21.0, 0, 0, '13502', 77.9583, 'D9', 'S']\n",
- "[630, 631, 1, 1, 'Barkworth, Mr. Algernon Henry Wilson', 'male', 80.0, 0, 0, '27042', 30.0, 'A23', 'S']\n",
- "[632, 633, 1, 1, 'Stahelin-Maeglin, Dr. Max', 'male', 32.0, 0, 0, '13214', 30.5, 'B50', 'C']\n",
- "[633, 634, 0, 1, 'Parr, Mr. William Henry Marsh', 'male', nan, 0, 0, '112052', 0.0, nan, 'S']\n",
- "[641, 642, 1, 1, 'Sagesser, Mlle. Emma', 'female', 24.0, 0, 0, 'PC 17477', 69.3, 'B35', 'C']\n",
- "[645, 646, 1, 1, 'Harper, Mr. Henry Sleeper', 'male', 48.0, 1, 0, 'PC 17572', 76.7292, 'D33', 'C']\n",
- "[647, 648, 1, 1, 'Simonius-Blumer, Col. Oberst Alfons', 'male', 56.0, 0, 0, '13213', 35.5, 'A26', 'C']\n",
- "[659, 660, 0, 1, 'Newell, Mr. Arthur Webster', 'male', 58.0, 0, 2, '35273', 113.275, 'D48', 'C']\n",
- "[660, 661, 1, 1, 'Frauenthal, Dr. Henry William', 'male', 50.0, 2, 0, 'PC 17611', 133.65, nan, 'S']\n",
- "[662, 663, 0, 1, 'Colley, Mr. Edward Pomeroy', 'male', 47.0, 0, 0, '5727', 25.5875, 'E58', 'S']\n",
- "[669, 670, 1, 1, 'Taylor, Mrs. Elmer Zebley (Juliet Cummins Wright)', 'female', nan, 1, 0, '19996', 52.0, 'C126', 'S']\n",
- "[671, 672, 0, 1, 'Davidson, Mr. Thornton', 'male', 31.0, 1, 0, 'F.C. 12750', 52.0, 'B71', 'S']\n",
- "[679, 680, 1, 1, 'Cardeza, Mr. Thomas Drake Martinez', 'male', 36.0, 0, 1, 'PC 17755', 512.3292, 'B51 B53 B55', 'C']\n",
- "[681, 682, 1, 1, 'Hassab, Mr. Hammad', 'male', 27.0, 0, 0, 'PC 17572', 76.7292, 'D49', 'C']\n",
- "[689, 690, 1, 1, 'Madill, Miss. Georgette Alexandra', 'female', 15.0, 0, 1, '24160', 211.3375, 'B5', 'S']\n",
- "[690, 691, 1, 1, 'Dick, Mr. Albert Adrian', 'male', 31.0, 1, 0, '17474', 57.0, 'B20', 'S']\n",
- "[694, 695, 0, 1, 'Weir, Col. John', 'male', 60.0, 0, 0, '113800', 26.55, nan, 'S']\n",
- "[698, 699, 0, 1, 'Thayer, Mr. John Borland', 'male', 49.0, 1, 1, '17421', 110.8833, 'C68', 'C']\n",
- "[700, 701, 1, 1, 'Astor, Mrs. John Jacob (Madeleine Talmadge Force)', 'female', 18.0, 1, 0, 'PC 17757', 227.525, 'C62 C64', 'C']\n",
- "[701, 702, 1, 1, 'Silverthorne, Mr. Spencer Victor', 'male', 35.0, 0, 0, 'PC 17475', 26.2875, 'E24', 'S']\n",
- "[707, 708, 1, 1, 'Calderhead, Mr. Edward Pennington', 'male', 42.0, 0, 0, 'PC 17476', 26.2875, 'E24', 'S']\n",
- "[708, 709, 1, 1, 'Cleaver, Miss. Alice', 'female', 22.0, 0, 0, '113781', 151.55, nan, 'S']\n",
- "[710, 711, 1, 1, 'Mayne, Mlle. Berthe Antonine (\"Mrs de Villiers\")', 'female', 24.0, 0, 0, 'PC 17482', 49.5042, 'C90', 'C']\n",
- "[711, 712, 0, 1, 'Klaber, Mr. Herman', 'male', nan, 0, 0, '113028', 26.55, 'C124', 'S']\n",
- "[712, 713, 1, 1, 'Taylor, Mr. Elmer Zebley', 'male', 48.0, 1, 0, '19996', 52.0, 'C126', 'S']\n",
- "[716, 717, 1, 1, 'Endres, Miss. Caroline Louise', 'female', 38.0, 0, 0, 'PC 17757', 227.525, 'C45', 'C']\n",
- "[724, 725, 1, 1, 'Chambers, Mr. Norman Campbell', 'male', 27.0, 1, 0, '113806', 53.1, 'E8', 'S']\n",
- "[730, 731, 1, 1, 'Allen, Miss. Elisabeth Walton', 'female', 29.0, 0, 0, '24160', 211.3375, 'B5', 'S']\n",
- "[737, 738, 1, 1, 'Lesurer, Mr. Gustave J', 'male', 35.0, 0, 0, 'PC 17755', 512.3292, 'B101', 'C']\n",
- "[740, 741, 1, 1, 'Hawksford, Mr. Walter James', 'male', nan, 0, 0, '16988', 30.0, 'D45', 'S']\n",
- "[741, 742, 0, 1, 'Cavendish, Mr. Tyrell William', 'male', 36.0, 1, 0, '19877', 78.85, 'C46', 'S']\n",
- "[742, 743, 1, 1, 'Ryerson, Miss. Susan Parker \"Suzette\"', 'female', 21.0, 2, 2, 'PC 17608', 262.375, 'B57 B59 B63 B66', 'C']\n",
- "[745, 746, 0, 1, 'Crosby, Capt. Edward Gifford', 'male', 70.0, 1, 1, 'WE/P 5735', 71.0, 'B22', 'S']\n",
- "[748, 749, 0, 1, 'Marvin, Mr. Daniel Warner', 'male', 19.0, 1, 0, '113773', 53.1, 'D30', 'S']\n",
- "[759, 760, 1, 1, 'Rothes, the Countess. of (Lucy Noel Martha Dyer-Edwards)', 'female', 33.0, 0, 0, '110152', 86.5, 'B77', 'S']\n",
- "[763, 764, 1, 1, 'Carter, Mrs. William Ernest (Lucile Polk)', 'female', 36.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
- "[765, 766, 1, 1, 'Hogeboom, Mrs. John C (Anna Andrews)', 'female', 51.0, 1, 0, '13502', 77.9583, 'D11', 'S']\n",
- "[766, 767, 0, 1, 'Brewe, Dr. Arthur Jackson', 'male', nan, 0, 0, '112379', 39.6, nan, 'C']\n",
- "[779, 780, 1, 1, 'Robert, Mrs. Edward Scott (Elisabeth Walton McMillan)', 'female', 43.0, 0, 1, '24160', 211.3375, 'B3', 'S']\n",
- "[781, 782, 1, 1, 'Dick, Mrs. Albert Adrian (Vera Gillespie)', 'female', 17.0, 1, 0, '17474', 57.0, 'B20', 'S']\n",
- "[782, 783, 0, 1, 'Long, Mr. Milton Clyde', 'male', 29.0, 0, 0, '113501', 30.0, 'D6', 'S']\n",
- "[789, 790, 0, 1, 'Guggenheim, Mr. Benjamin', 'male', 46.0, 0, 0, 'PC 17593', 79.2, 'B82 B84', 'C']\n",
- "[793, 794, 0, 1, 'Hoyt, Mr. William Fisher', 'male', nan, 0, 0, 'PC 17600', 30.6958, nan, 'C']\n",
- "[796, 797, 1, 1, 'Leader, Dr. Alice (Farnham)', 'female', 49.0, 0, 0, '17465', 25.9292, 'D17', 'S']\n",
- "[802, 803, 1, 1, 'Carter, Master. William Thornton II', 'male', 11.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
- "[806, 807, 0, 1, 'Andrews, Mr. Thomas Jr', 'male', 39.0, 0, 0, '112050', 0.0, 'A36', 'S']\n",
- "[809, 810, 1, 1, 'Chambers, Mrs. Norman Campbell (Bertha Griggs)', 'female', 33.0, 1, 0, '113806', 53.1, 'E8', 'S']\n",
- "[815, 816, 0, 1, 'Fry, Mr. Richard', 'male', nan, 0, 0, '112058', 0.0, 'B102', 'S']\n",
- "[820, 821, 1, 1, 'Hays, Mrs. Charles Melville (Clara Jennings Gregg)', 'female', 52.0, 1, 1, '12749', 93.5, 'B69', 'S']\n",
- "[822, 823, 0, 1, 'Reuchlin, Jonkheer. John George', 'male', 38.0, 0, 0, '19972', 0.0, nan, 'S']\n",
- "[829, 830, 1, 1, 'Stone, Mrs. George Nelson (Martha Evelyn)', 'female', 62.0, 0, 0, '113572', 80.0, 'B28', nan]\n",
- "[835, 836, 1, 1, 'Compton, Miss. Sara Rebecca', 'female', 39.0, 1, 1, 'PC 17756', 83.1583, 'E49', 'C']\n",
- "[839, 840, 1, 1, 'Marechal, Mr. Pierre', 'male', nan, 0, 0, '11774', 29.7, 'C47', 'C']\n",
- "[842, 843, 1, 1, 'Serepeca, Miss. Augusta', 'female', 30.0, 0, 0, '113798', 31.0, nan, 'C']\n",
- "[849, 850, 1, 1, 'Goldenberg, Mrs. Samuel L (Edwiga Grabowska)', 'female', nan, 1, 0, '17453', 89.1042, 'C92', 'C']\n",
- "[853, 854, 1, 1, 'Lines, Miss. Mary Conover', 'female', 16.0, 0, 1, 'PC 17592', 39.4, 'D28', 'S']\n",
- "[856, 857, 1, 1, 'Wick, Mrs. George Dennick (Mary Hitchcock)', 'female', 45.0, 1, 1, '36928', 164.8667, nan, 'S']\n",
- "[857, 858, 1, 1, 'Daly, Mr. Peter Denis ', 'male', 51.0, 0, 0, '113055', 26.55, 'E17', 'S']\n",
- "[862, 863, 1, 1, 'Swift, Mrs. Frederick Joel (Margaret Welles Barron)', 'female', 48.0, 0, 0, '17466', 25.9292, 'D17', 'S']\n",
- "[867, 868, 0, 1, 'Roebling, Mr. Washington Augustus II', 'male', 31.0, 0, 0, 'PC 17590', 50.4958, 'A24', 'S']\n",
- "[871, 872, 1, 1, 'Beckwith, Mrs. Richard Leonard (Sallie Monypeny)', 'female', 47.0, 1, 1, '11751', 52.5542, 'D35', 'S']\n",
- "[872, 873, 0, 1, 'Carlsson, Mr. Frans Olof', 'male', 33.0, 0, 0, '695', 5.0, 'B51 B53 B55', 'S']\n",
- "[879, 880, 1, 1, 'Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)', 'female', 56.0, 0, 1, '11767', 83.1583, 'C50', 'C']\n",
- "[887, 888, 1, 1, 'Graham, Miss. Margaret Edith', 'female', 19.0, 0, 0, '112053', 30.0, 'B42', 'S']\n",
- "[889, 890, 1, 1, 'Behr, Mr. Karl Howell', 'male', 26.0, 0, 0, '111369', 30.0, 'C148', 'C']\n"
- ]
- }
- ],
- "source": [
- "# dataframe_to_rowsを用いるとデータフレームを配列形式に変換してくれます。\n",
- "for row in dataframe_to_rows(df) :\n",
- " print(row)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "#### *それではappendを用いて、Pclass1のシートにデータフレームの値を記述していきましょう!*"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 45,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# データフレームからExcelへ\n",
- "for row in dataframe_to_rows(df) :\n",
- " ws.append(row)\n",
- "\n",
- "# Excelに保存をします。\n",
- "wb.save(excel_file)"
- ]
- },
- {
- "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.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Add Comment
Please, Sign In to add comment