Guest User

Untitled

a guest
Oct 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.44 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "----------\n",
  8. "## *1. セル値の読み込みと書き込みを使う場面*"
  9. ]
  10. },
  11. {
  12. "cell_type": "code",
  13. "execution_count": null,
  14. "metadata": {
  15. "collapsed": true
  16. },
  17. "outputs": [],
  18. "source": [
  19. "# 3つのデータを一括で貼り付けます。\n",
  20. "for i , title in enumerate(title_names) :\n",
  21. " # シートの作成\n",
  22. " report_wb.create_sheet(title)\n",
  23. " # シートの読み込み\n",
  24. " report_ws = report_wb.get_sheet_by_name(title)\n",
  25. " \n",
  26. " # セル値の読み込みと書き込み\n",
  27. " for column_num in range(1,reports[i].max_column) : \n",
  28. " for row_num in range(1,reports[i].max_row) :\n",
  29. " report_ws.cell(row=row_num,column=column_num).value = reports[i].cell(row=row_num,column=column_num).value\n",
  30. " report_wb.save('report.xlsx')"
  31. ]
  32. },
  33. {
  34. "cell_type": "markdown",
  35. "metadata": {},
  36. "source": [
  37. "----------\n",
  38. "## 2. セルの取得\n"
  39. ]
  40. },
  41. {
  42. "cell_type": "code",
  43. "execution_count": 4,
  44. "metadata": {},
  45. "outputs": [],
  46. "source": [
  47. "# 今回はタイタニックデータを用いていきます。\n",
  48. "# タイタニックデータはCSV形式なので、一旦Excel形式に変換をします。\n",
  49. "import pandas as pd\n",
  50. "df = pd.read_csv('/Users/yanomekeita/dhu/train.csv')\n",
  51. "df.to_excel('train.xlsx',sheet_name = 'titanic_data')"
  52. ]
  53. },
  54. {
  55. "cell_type": "code",
  56. "execution_count": 11,
  57. "metadata": {},
  58. "outputs": [
  59. {
  60. "data": {
  61. "text/plain": [
  62. "'Survived'"
  63. ]
  64. },
  65. "execution_count": 11,
  66. "metadata": {},
  67. "output_type": "execute_result"
  68. }
  69. ],
  70. "source": [
  71. "# Excelファイル名を変数に格納します。\n",
  72. "excel_file = '/Users/yanomekeita/dhu/train.xlsx'\n",
  73. "\n",
  74. "# openpyxlライブラリとExcelファイルを起動します。\n",
  75. "import openpyxl as px\n",
  76. "wb = px.load_workbook(excel_file)\n",
  77. "\n",
  78. "# アクティブシートを読み取ります。\n",
  79. "ws = wb.active"
  80. ]
  81. },
  82. {
  83. "cell_type": "code",
  84. "execution_count": 14,
  85. "metadata": {},
  86. "outputs": [
  87. {
  88. "data": {
  89. "text/plain": [
  90. "'書き込みテスト'"
  91. ]
  92. },
  93. "execution_count": 14,
  94. "metadata": {},
  95. "output_type": "execute_result"
  96. }
  97. ],
  98. "source": [
  99. "# セル値の取得ver1\n",
  100. "ws['C1'].value\n",
  101. "\n",
  102. "# セル値の取得ver2\n",
  103. "ws.cell(row= 1,column = 1).value"
  104. ]
  105. },
  106. {
  107. "cell_type": "markdown",
  108. "metadata": {},
  109. "source": [
  110. "----------\n",
  111. "## 3. 複数セルの取得"
  112. ]
  113. },
  114. {
  115. "cell_type": "code",
  116. "execution_count": 21,
  117. "metadata": {},
  118. "outputs": [
  119. {
  120. "name": "stdout",
  121. "output_type": "stream",
  122. "text": [
  123. "書き込みテスト\n",
  124. "PassengerId\n",
  125. "Survived\n",
  126. "Pclass\n",
  127. "Name\n",
  128. "Sex\n",
  129. "Age\n",
  130. "SibSp\n",
  131. "Parch\n",
  132. "Ticket\n",
  133. "Fare\n",
  134. "Cabin\n"
  135. ]
  136. }
  137. ],
  138. "source": [
  139. "# train.xlsxの1行目(横方向)の全ての値を取得してみましょう!\n",
  140. "\n",
  141. "\n",
  142. "# まずはtrain.xlsxファイルの列数が何個なのかを算出してみましょう。\n",
  143. "ws.max_column\n",
  144. "\n",
  145. "\n",
  146. "# それでは、max_columnを用いて複数セルの取得を実行していきます。\n",
  147. "for column_num in range(1, ws.max_column) :\n",
  148. " print(ws.cell(row = 1 , column = column_num).value)"
  149. ]
  150. },
  151. {
  152. "cell_type": "code",
  153. "execution_count": 26,
  154. "metadata": {},
  155. "outputs": [],
  156. "source": [
  157. "# 次に1行の全ての値を取得していきます。\n",
  158. "for row_num in range(1, ws.max_row) : \n",
  159. " ws.cell(row = row_num,column = 1).value"
  160. ]
  161. },
  162. {
  163. "cell_type": "code",
  164. "execution_count": 27,
  165. "metadata": {
  166. "collapsed": true
  167. },
  168. "outputs": [],
  169. "source": [
  170. "# 全データを一括で取得します。\n",
  171. "for column_num in range(1, ws.max_column) :\n",
  172. " for row_num in range(1, ws.max_row) :\n",
  173. " ws.cell(row = row_num , column = column_num)"
  174. ]
  175. },
  176. {
  177. "cell_type": "markdown",
  178. "metadata": {},
  179. "source": [
  180. "----------\n",
  181. "## 4. セルの書き込み\n"
  182. ]
  183. },
  184. {
  185. "cell_type": "code",
  186. "execution_count": 28,
  187. "metadata": {
  188. "collapsed": true
  189. },
  190. "outputs": [],
  191. "source": [
  192. "# 先ほどのtrain.xlsxを使用していきます。\n",
  193. "wb = px.load_workbook(excel_file)\n",
  194. "ws = wb.active\n",
  195. "\n",
  196. "# アクティブシートのセルに値を書き込んでいきます。\n",
  197. "ws['A1'].value = '書き込み'\n",
  198. "\n",
  199. "# Excelを保存します。\n",
  200. "wb.save(excel_file)"
  201. ]
  202. },
  203. {
  204. "cell_type": "markdown",
  205. "metadata": {},
  206. "source": [
  207. "----------\n",
  208. "## 5. 【小テスト1】シートのコピー\n",
  209. "**【内容】**\n",
  210. "\n",
  211. "別シートを作成し、train.xlsxのデータを丸々コピペしてみましょう。\n",
  212. "\n",
  213. "\n",
  214. "**【手順】**\n",
  215. "1. train.xlsxファイルの中に別シートを作成します。\n",
  216. "2. train.xlsxのシートのセル値を全て取得します。\n",
  217. "3. 新たに作成したシートのセルに、train.xlsxのセル値を書き込みます。"
  218. ]
  219. },
  220. {
  221. "cell_type": "code",
  222. "execution_count": 29,
  223. "metadata": {
  224. "collapsed": true
  225. },
  226. "outputs": [],
  227. "source": [
  228. "# 先ほどのtrain.xlsxを使用していきます。\n",
  229. "wb = px.load_workbook(excel_file)\n",
  230. "ws = wb.active"
  231. ]
  232. },
  233. {
  234. "cell_type": "code",
  235. "execution_count": 30,
  236. "metadata": {
  237. "collapsed": true
  238. },
  239. "outputs": [],
  240. "source": [
  241. "# シートの作成\n",
  242. "copy_ws = wb.create_sheet('copy_titanic_data')"
  243. ]
  244. },
  245. {
  246. "cell_type": "code",
  247. "execution_count": 32,
  248. "metadata": {
  249. "collapsed": true
  250. },
  251. "outputs": [],
  252. "source": [
  253. "# train.xlsxにあるデータを取得していきます。\n",
  254. "for column_num in range(1, ws.max_column):\n",
  255. " for row_num in range(1, ws.max_row):\n",
  256. " # セル値を新しく作成したシートに貼り付けます。\n",
  257. " copy_ws.cell(row = row_num , column = column_num).value = ws.cell(row = row_num , column = column_num).value\n",
  258. "\n",
  259. "# Excelファイルを保存して終了です。\n",
  260. "wb.save(excel_file)"
  261. ]
  262. },
  263. {
  264. "cell_type": "markdown",
  265. "metadata": {},
  266. "source": [
  267. "------------------------------------------------------------------------\n",
  268. "## 6.【小テスト2】条件別にExcelシートを作成する\n",
  269. "**【内容】**\n",
  270. "Pclass1の人だけを抽出し、新規シートを作成しそこに保存をしてみましょう。\n",
  271. "\n",
  272. "**【手順】**\n",
  273. "1. データフレームで、データを必要な形に変換します。\n",
  274. "2. 新たなシートを作成します。\n",
  275. "3. 新規作成したシートに、変換したデータをExcelに貼り付けます。"
  276. ]
  277. },
  278. {
  279. "cell_type": "code",
  280. "execution_count": 35,
  281. "metadata": {},
  282. "outputs": [
  283. {
  284. "data": {
  285. "text/html": [
  286. "<div>\n",
  287. "<style>\n",
  288. " .dataframe thead tr:only-child th {\n",
  289. " text-align: right;\n",
  290. " }\n",
  291. "\n",
  292. " .dataframe thead th {\n",
  293. " text-align: left;\n",
  294. " }\n",
  295. "\n",
  296. " .dataframe tbody tr th {\n",
  297. " vertical-align: top;\n",
  298. " }\n",
  299. "</style>\n",
  300. "<table border=\"1\" class=\"dataframe\">\n",
  301. " <thead>\n",
  302. " <tr style=\"text-align: right;\">\n",
  303. " <th></th>\n",
  304. " <th>PassengerId</th>\n",
  305. " <th>Survived</th>\n",
  306. " <th>Pclass</th>\n",
  307. " <th>Name</th>\n",
  308. " <th>Sex</th>\n",
  309. " <th>Age</th>\n",
  310. " <th>SibSp</th>\n",
  311. " <th>Parch</th>\n",
  312. " <th>Ticket</th>\n",
  313. " <th>Fare</th>\n",
  314. " <th>Cabin</th>\n",
  315. " <th>Embarked</th>\n",
  316. " </tr>\n",
  317. " </thead>\n",
  318. " <tbody>\n",
  319. " <tr>\n",
  320. " <th>1</th>\n",
  321. " <td>2</td>\n",
  322. " <td>1</td>\n",
  323. " <td>1</td>\n",
  324. " <td>Cumings, Mrs. John Bradley (Florence Briggs Th...</td>\n",
  325. " <td>female</td>\n",
  326. " <td>38.0</td>\n",
  327. " <td>1</td>\n",
  328. " <td>0</td>\n",
  329. " <td>PC 17599</td>\n",
  330. " <td>71.2833</td>\n",
  331. " <td>C85</td>\n",
  332. " <td>C</td>\n",
  333. " </tr>\n",
  334. " <tr>\n",
  335. " <th>3</th>\n",
  336. " <td>4</td>\n",
  337. " <td>1</td>\n",
  338. " <td>1</td>\n",
  339. " <td>Futrelle, Mrs. Jacques Heath (Lily May Peel)</td>\n",
  340. " <td>female</td>\n",
  341. " <td>35.0</td>\n",
  342. " <td>1</td>\n",
  343. " <td>0</td>\n",
  344. " <td>113803</td>\n",
  345. " <td>53.1000</td>\n",
  346. " <td>C123</td>\n",
  347. " <td>S</td>\n",
  348. " </tr>\n",
  349. " <tr>\n",
  350. " <th>6</th>\n",
  351. " <td>7</td>\n",
  352. " <td>0</td>\n",
  353. " <td>1</td>\n",
  354. " <td>McCarthy, Mr. Timothy J</td>\n",
  355. " <td>male</td>\n",
  356. " <td>54.0</td>\n",
  357. " <td>0</td>\n",
  358. " <td>0</td>\n",
  359. " <td>17463</td>\n",
  360. " <td>51.8625</td>\n",
  361. " <td>E46</td>\n",
  362. " <td>S</td>\n",
  363. " </tr>\n",
  364. " <tr>\n",
  365. " <th>11</th>\n",
  366. " <td>12</td>\n",
  367. " <td>1</td>\n",
  368. " <td>1</td>\n",
  369. " <td>Bonnell, Miss. Elizabeth</td>\n",
  370. " <td>female</td>\n",
  371. " <td>58.0</td>\n",
  372. " <td>0</td>\n",
  373. " <td>0</td>\n",
  374. " <td>113783</td>\n",
  375. " <td>26.5500</td>\n",
  376. " <td>C103</td>\n",
  377. " <td>S</td>\n",
  378. " </tr>\n",
  379. " <tr>\n",
  380. " <th>23</th>\n",
  381. " <td>24</td>\n",
  382. " <td>1</td>\n",
  383. " <td>1</td>\n",
  384. " <td>Sloper, Mr. William Thompson</td>\n",
  385. " <td>male</td>\n",
  386. " <td>28.0</td>\n",
  387. " <td>0</td>\n",
  388. " <td>0</td>\n",
  389. " <td>113788</td>\n",
  390. " <td>35.5000</td>\n",
  391. " <td>A6</td>\n",
  392. " <td>S</td>\n",
  393. " </tr>\n",
  394. " </tbody>\n",
  395. "</table>\n",
  396. "</div>"
  397. ],
  398. "text/plain": [
  399. " PassengerId Survived Pclass \\\n",
  400. "1 2 1 1 \n",
  401. "3 4 1 1 \n",
  402. "6 7 0 1 \n",
  403. "11 12 1 1 \n",
  404. "23 24 1 1 \n",
  405. "\n",
  406. " Name Sex Age SibSp \\\n",
  407. "1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 \n",
  408. "3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 \n",
  409. "6 McCarthy, Mr. Timothy J male 54.0 0 \n",
  410. "11 Bonnell, Miss. Elizabeth female 58.0 0 \n",
  411. "23 Sloper, Mr. William Thompson male 28.0 0 \n",
  412. "\n",
  413. " Parch Ticket Fare Cabin Embarked \n",
  414. "1 0 PC 17599 71.2833 C85 C \n",
  415. "3 0 113803 53.1000 C123 S \n",
  416. "6 0 17463 51.8625 E46 S \n",
  417. "11 0 113783 26.5500 C103 S \n",
  418. "23 0 113788 35.5000 A6 S "
  419. ]
  420. },
  421. "execution_count": 35,
  422. "metadata": {},
  423. "output_type": "execute_result"
  424. }
  425. ],
  426. "source": [
  427. "# Pandasとデータのインポート\n",
  428. "import pandas as pd\n",
  429. "df = pd.read_csv('/Users/yanomekeita/dhu/train.csv')\n",
  430. "\n",
  431. "# データフレームで、Pclass1の人だけに加工をします。\n",
  432. "df = df[df.Pclass ==1]\n",
  433. "df.head()"
  434. ]
  435. },
  436. {
  437. "cell_type": "markdown",
  438. "metadata": {},
  439. "source": [
  440. "#### *変換したデータフレームをExcelファイルに書き込んでいきます。*"
  441. ]
  442. },
  443. {
  444. "cell_type": "code",
  445. "execution_count": 37,
  446. "metadata": {},
  447. "outputs": [],
  448. "source": [
  449. "# ライブラリのインポート\n",
  450. "from openpyxl.utils.dataframe import dataframe_to_rows\n",
  451. "\n",
  452. "# Excelファイルの読みこみ\n",
  453. "wb = px.load_workbook(excel_file)\n",
  454. "\n",
  455. "# 新たなシートを作成し、シートの読み込みを行います。\n",
  456. "ws = wb.create_sheet('Pclass1')"
  457. ]
  458. },
  459. {
  460. "cell_type": "code",
  461. "execution_count": 42,
  462. "metadata": {},
  463. "outputs": [],
  464. "source": [
  465. "# appendで、セルに書き込みをすることが可能です。\n",
  466. "ws.append(['test','です'])\n",
  467. "wb.save(excel_file)"
  468. ]
  469. },
  470. {
  471. "cell_type": "code",
  472. "execution_count": 44,
  473. "metadata": {},
  474. "outputs": [
  475. {
  476. "name": "stdout",
  477. "output_type": "stream",
  478. "text": [
  479. "[None, 'PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp', 'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked']\n",
  480. "[1, 2, 1, 1, 'Cumings, Mrs. John Bradley (Florence Briggs Thayer)', 'female', 38.0, 1, 0, 'PC 17599', 71.2833, 'C85', 'C']\n",
  481. "[3, 4, 1, 1, 'Futrelle, Mrs. Jacques Heath (Lily May Peel)', 'female', 35.0, 1, 0, '113803', 53.1, 'C123', 'S']\n",
  482. "[6, 7, 0, 1, 'McCarthy, Mr. Timothy J', 'male', 54.0, 0, 0, '17463', 51.8625, 'E46', 'S']\n",
  483. "[11, 12, 1, 1, 'Bonnell, Miss. Elizabeth', 'female', 58.0, 0, 0, '113783', 26.55, 'C103', 'S']\n",
  484. "[23, 24, 1, 1, 'Sloper, Mr. William Thompson', 'male', 28.0, 0, 0, '113788', 35.5, 'A6', 'S']\n",
  485. "[27, 28, 0, 1, 'Fortune, Mr. Charles Alexander', 'male', 19.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
  486. "[30, 31, 0, 1, 'Uruchurtu, Don. Manuel E', 'male', 40.0, 0, 0, 'PC 17601', 27.7208, nan, 'C']\n",
  487. "[31, 32, 1, 1, 'Spencer, Mrs. William Augustus (Marie Eugenie)', 'female', nan, 1, 0, 'PC 17569', 146.5208, 'B78', 'C']\n",
  488. "[34, 35, 0, 1, 'Meyer, Mr. Edgar Joseph', 'male', 28.0, 1, 0, 'PC 17604', 82.1708, nan, 'C']\n",
  489. "[35, 36, 0, 1, 'Holverson, Mr. Alexander Oskar', 'male', 42.0, 1, 0, '113789', 52.0, nan, 'S']\n",
  490. "[52, 53, 1, 1, 'Harper, Mrs. Henry Sleeper (Myna Haxtun)', 'female', 49.0, 1, 0, 'PC 17572', 76.7292, 'D33', 'C']\n",
  491. "[54, 55, 0, 1, 'Ostby, Mr. Engelhart Cornelius', 'male', 65.0, 0, 1, '113509', 61.9792, 'B30', 'C']\n",
  492. "[55, 56, 1, 1, 'Woolner, Mr. Hugh', 'male', nan, 0, 0, '19947', 35.5, 'C52', 'S']\n",
  493. "[61, 62, 1, 1, 'Icard, Miss. Amelie', 'female', 38.0, 0, 0, '113572', 80.0, 'B28', nan]\n",
  494. "[62, 63, 0, 1, 'Harris, Mr. Henry Birkhardt', 'male', 45.0, 1, 0, '36973', 83.475, 'C83', 'S']\n",
  495. "[64, 65, 0, 1, 'Stewart, Mr. Albert A', 'male', nan, 0, 0, 'PC 17605', 27.7208, nan, 'C']\n",
  496. "[83, 84, 0, 1, 'Carrau, Mr. Francisco M', 'male', 28.0, 0, 0, '113059', 47.1, nan, 'S']\n",
  497. "[88, 89, 1, 1, 'Fortune, Miss. Mabel Helen', 'female', 23.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
  498. "[92, 93, 0, 1, 'Chaffee, Mr. Herbert Fuller', 'male', 46.0, 1, 0, 'W.E.P. 5734', 61.175, 'E31', 'S']\n",
  499. "[96, 97, 0, 1, 'Goldschmidt, Mr. George B', 'male', 71.0, 0, 0, 'PC 17754', 34.6542, 'A5', 'C']\n",
  500. "[97, 98, 1, 1, 'Greenfield, Mr. William Bertram', 'male', 23.0, 0, 1, 'PC 17759', 63.3583, 'D10 D12', 'C']\n",
  501. "[102, 103, 0, 1, 'White, Mr. Richard Frasar', 'male', 21.0, 0, 1, '35281', 77.2875, 'D26', 'S']\n",
  502. "[110, 111, 0, 1, 'Porter, Mr. Walter Chamberlain', 'male', 47.0, 0, 0, '110465', 52.0, 'C110', 'S']\n",
  503. "[118, 119, 0, 1, 'Baxter, Mr. Quigg Edmond', 'male', 24.0, 0, 1, 'PC 17558', 247.5208, 'B58 B60', 'C']\n",
  504. "[124, 125, 0, 1, 'White, Mr. Percival Wayland', 'male', 54.0, 0, 1, '35281', 77.2875, 'D26', 'S']\n",
  505. "[136, 137, 1, 1, 'Newsom, Miss. Helen Monypeny', 'female', 19.0, 0, 2, '11752', 26.2833, 'D47', 'S']\n",
  506. "[137, 138, 0, 1, 'Futrelle, Mr. Jacques Heath', 'male', 37.0, 1, 0, '113803', 53.1, 'C123', 'S']\n",
  507. "[139, 140, 0, 1, 'Giglio, Mr. Victor', 'male', 24.0, 0, 0, 'PC 17593', 79.2, 'B86', 'C']\n",
  508. "[151, 152, 1, 1, 'Pears, Mrs. Thomas (Edith Wearne)', 'female', 22.0, 1, 0, '113776', 66.6, 'C2', 'S']\n",
  509. "[155, 156, 0, 1, 'Williams, Mr. Charles Duane', 'male', 51.0, 0, 1, 'PC 17597', 61.3792, nan, 'C']\n",
  510. "[166, 167, 1, 1, 'Chibnall, Mrs. (Edith Martha Bowerman)', 'female', nan, 0, 1, '113505', 55.0, 'E33', 'S']\n",
  511. "[168, 169, 0, 1, 'Baumann, Mr. John D', 'male', nan, 0, 0, 'PC 17318', 25.925, nan, 'S']\n",
  512. "[170, 171, 0, 1, 'Van der hoef, Mr. Wyckoff', 'male', 61.0, 0, 0, '111240', 33.5, 'B19', 'S']\n",
  513. "[174, 175, 0, 1, 'Smith, Mr. James Clinch', 'male', 56.0, 0, 0, '17764', 30.6958, 'A7', 'C']\n",
  514. "[177, 178, 0, 1, 'Isham, Miss. Ann Elizabeth', 'female', 50.0, 0, 0, 'PC 17595', 28.7125, 'C49', 'C']\n",
  515. "[185, 186, 0, 1, 'Rood, Mr. Hugh Roscoe', 'male', nan, 0, 0, '113767', 50.0, 'A32', 'S']\n",
  516. "[187, 188, 1, 1, 'Romaine, Mr. Charles Hallace (\"Mr C Rolmane\")', 'male', 45.0, 0, 0, '111428', 26.55, nan, 'S']\n",
  517. "[194, 195, 1, 1, 'Brown, Mrs. James Joseph (Margaret Tobin)', 'female', 44.0, 0, 0, 'PC 17610', 27.7208, 'B4', 'C']\n",
  518. "[195, 196, 1, 1, 'Lurette, Miss. Elise', 'female', 58.0, 0, 0, 'PC 17569', 146.5208, 'B80', 'C']\n",
  519. "[209, 210, 1, 1, 'Blank, Mr. Henry', 'male', 40.0, 0, 0, '112277', 31.0, 'A31', 'C']\n",
  520. "[215, 216, 1, 1, 'Newell, Miss. Madeleine', 'female', 31.0, 1, 0, '35273', 113.275, 'D36', 'C']\n",
  521. "[218, 219, 1, 1, 'Bazzani, Miss. Albina', 'female', 32.0, 0, 0, '11813', 76.2917, 'D15', 'C']\n",
  522. "[224, 225, 1, 1, 'Hoyt, Mr. Frederick Maxfield', 'male', 38.0, 1, 0, '19943', 90.0, 'C93', 'S']\n",
  523. "[230, 231, 1, 1, 'Harris, Mrs. Henry Birkhardt (Irene Wallach)', 'female', 35.0, 1, 0, '36973', 83.475, 'C83', 'S']\n",
  524. "[245, 246, 0, 1, 'Minahan, Dr. William Edward', 'male', 44.0, 2, 0, '19928', 90.0, 'C78', 'Q']\n",
  525. "[248, 249, 1, 1, 'Beckwith, Mr. Richard Leonard', 'male', 37.0, 1, 1, '11751', 52.5542, 'D35', 'S']\n",
  526. "[252, 253, 0, 1, 'Stead, Mr. William Thomas', 'male', 62.0, 0, 0, '113514', 26.55, 'C87', 'S']\n",
  527. "[256, 257, 1, 1, 'Thorne, Mrs. Gertrude Maybelle', 'female', nan, 0, 0, 'PC 17585', 79.2, nan, 'C']\n",
  528. "[257, 258, 1, 1, 'Cherry, Miss. Gladys', 'female', 30.0, 0, 0, '110152', 86.5, 'B77', 'S']\n",
  529. "[258, 259, 1, 1, 'Ward, Miss. Anna', 'female', 35.0, 0, 0, 'PC 17755', 512.3292, nan, 'C']\n",
  530. "[262, 263, 0, 1, 'Taussig, Mr. Emil', 'male', 52.0, 1, 1, '110413', 79.65, 'E67', 'S']\n",
  531. "[263, 264, 0, 1, 'Harrison, Mr. William', 'male', 40.0, 0, 0, '112059', 0.0, 'B94', 'S']\n",
  532. "[268, 269, 1, 1, 'Graham, Mrs. William Thompson (Edith Junkins)', 'female', 58.0, 0, 1, 'PC 17582', 153.4625, 'C125', 'S']\n",
  533. "[269, 270, 1, 1, 'Bissette, Miss. Amelia', 'female', 35.0, 0, 0, 'PC 17760', 135.6333, 'C99', 'S']\n",
  534. "[270, 271, 0, 1, 'Cairns, Mr. Alexander', 'male', nan, 0, 0, '113798', 31.0, nan, 'S']\n",
  535. "[273, 274, 0, 1, 'Natsch, Mr. Charles H', 'male', 37.0, 0, 1, 'PC 17596', 29.7, 'C118', 'C']\n",
  536. "[275, 276, 1, 1, 'Andrews, Miss. Kornelia Theodosia', 'female', 63.0, 1, 0, '13502', 77.9583, 'D7', 'S']\n",
  537. "[284, 285, 0, 1, 'Smith, Mr. Richard William', 'male', nan, 0, 0, '113056', 26.0, 'A19', 'S']\n",
  538. "[290, 291, 1, 1, 'Barber, Miss. Ellen \"Nellie\"', 'female', 26.0, 0, 0, '19877', 78.85, nan, 'S']\n",
  539. "[291, 292, 1, 1, 'Bishop, Mrs. Dickinson H (Helen Walton)', 'female', 19.0, 1, 0, '11967', 91.0792, 'B49', 'C']\n",
  540. "[295, 296, 0, 1, 'Lewy, Mr. Ervin G', 'male', nan, 0, 0, 'PC 17612', 27.7208, nan, 'C']\n",
  541. "[297, 298, 0, 1, 'Allison, Miss. Helen Loraine', 'female', 2.0, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
  542. "[298, 299, 1, 1, 'Saalfeld, Mr. Adolphe', 'male', nan, 0, 0, '19988', 30.5, 'C106', 'S']\n",
  543. "[299, 300, 1, 1, 'Baxter, Mrs. James (Helene DeLaudeniere Chaput)', 'female', 50.0, 0, 1, 'PC 17558', 247.5208, 'B58 B60', 'C']\n",
  544. "[305, 306, 1, 1, 'Allison, Master. Hudson Trevor', 'male', 0.92, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
  545. "[306, 307, 1, 1, 'Fleming, Miss. Margaret', 'female', nan, 0, 0, '17421', 110.8833, nan, 'C']\n",
  546. "[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",
  547. "[309, 310, 1, 1, 'Francatelli, Miss. Laura Mabel', 'female', 30.0, 0, 0, 'PC 17485', 56.9292, 'E36', 'C']\n",
  548. "[310, 311, 1, 1, 'Hays, Miss. Margaret Bechstein', 'female', 24.0, 0, 0, '11767', 83.1583, 'C54', 'C']\n",
  549. "[311, 312, 1, 1, 'Ryerson, Miss. Emily Borie', 'female', 18.0, 2, 2, 'PC 17608', 262.375, 'B57 B59 B63 B66', 'C']\n",
  550. "[318, 319, 1, 1, 'Wick, Miss. Mary Natalie', 'female', 31.0, 0, 2, '36928', 164.8667, 'C7', 'S']\n",
  551. "[319, 320, 1, 1, 'Spedden, Mrs. Frederic Oakley (Margaretta Corning Stone)', 'female', 40.0, 1, 1, '16966', 134.5, 'E34', 'C']\n",
  552. "[325, 326, 1, 1, 'Young, Miss. Marie Grice', 'female', 36.0, 0, 0, 'PC 17760', 135.6333, 'C32', 'C']\n",
  553. "[329, 330, 1, 1, 'Hippach, Miss. Jean Gertrude', 'female', 16.0, 0, 1, '111361', 57.9792, 'B18', 'C']\n",
  554. "[331, 332, 0, 1, 'Partner, Mr. Austen', 'male', 45.5, 0, 0, '113043', 28.5, 'C124', 'S']\n",
  555. "[332, 333, 0, 1, 'Graham, Mr. George Edward', 'male', 38.0, 0, 1, 'PC 17582', 153.4625, 'C91', 'S']\n",
  556. "[334, 335, 1, 1, 'Frauenthal, Mrs. Henry William (Clara Heinsheimer)', 'female', nan, 1, 0, 'PC 17611', 133.65, nan, 'S']\n",
  557. "[336, 337, 0, 1, 'Pears, Mr. Thomas Clinton', 'male', 29.0, 1, 0, '113776', 66.6, 'C2', 'S']\n",
  558. "[337, 338, 1, 1, 'Burns, Miss. Elizabeth Margaret', 'female', 41.0, 0, 0, '16966', 134.5, 'E40', 'C']\n",
  559. "[339, 340, 0, 1, 'Blackwell, Mr. Stephen Weart', 'male', 45.0, 0, 0, '113784', 35.5, 'T', 'S']\n",
  560. "[341, 342, 1, 1, 'Fortune, Miss. Alice Elizabeth', 'female', 24.0, 3, 2, '19950', 263.0, 'C23 C25 C27', 'S']\n",
  561. "[351, 352, 0, 1, 'Williams-Lambert, Mr. Fletcher Fellows', 'male', nan, 0, 0, '113510', 35.0, 'C128', 'S']\n",
  562. "[356, 357, 1, 1, 'Bowerman, Miss. Elsie Edith', 'female', 22.0, 0, 1, '113505', 55.0, 'E33', 'S']\n",
  563. "[366, 367, 1, 1, 'Warren, Mrs. Frank Manley (Anna Sophia Atkinson)', 'female', 60.0, 1, 0, '110813', 75.25, 'D37', 'C']\n",
  564. "[369, 370, 1, 1, 'Aubart, Mme. Leontine Pauline', 'female', 24.0, 0, 0, 'PC 17477', 69.3, 'B35', 'C']\n",
  565. "[370, 371, 1, 1, 'Harder, Mr. George Achilles', 'male', 25.0, 1, 0, '11765', 55.4417, 'E50', 'C']\n",
  566. "[373, 374, 0, 1, 'Ringhini, Mr. Sante', 'male', 22.0, 0, 0, 'PC 17760', 135.6333, nan, 'C']\n",
  567. "[375, 376, 1, 1, 'Meyer, Mrs. Edgar Joseph (Leila Saks)', 'female', nan, 1, 0, 'PC 17604', 82.1708, nan, 'C']\n",
  568. "[377, 378, 0, 1, 'Widener, Mr. Harry Elkins', 'male', 27.0, 0, 2, '113503', 211.5, 'C82', 'C']\n",
  569. "[380, 381, 1, 1, 'Bidois, Miss. Rosalie', 'female', 42.0, 0, 0, 'PC 17757', 227.525, nan, 'C']\n",
  570. "[383, 384, 1, 1, 'Holverson, Mrs. Alexander Oskar (Mary Aline Towner)', 'female', 35.0, 1, 0, '113789', 52.0, nan, 'S']\n",
  571. "[390, 391, 1, 1, 'Carter, Mr. William Ernest', 'male', 36.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
  572. "[393, 394, 1, 1, 'Newell, Miss. Marjorie', 'female', 23.0, 1, 0, '35273', 113.275, 'D36', 'C']\n",
  573. "[412, 413, 1, 1, 'Minahan, Miss. Daisy E', 'female', 33.0, 1, 0, '19928', 90.0, 'C78', 'Q']\n",
  574. "[430, 431, 1, 1, 'Bjornstrom-Steffansson, Mr. Mauritz Hakan', 'male', 28.0, 0, 0, '110564', 26.55, 'C52', 'S']\n",
  575. "[434, 435, 0, 1, 'Silvey, Mr. William Baird', 'male', 50.0, 1, 0, '13507', 55.9, 'E44', 'S']\n",
  576. "[435, 436, 1, 1, 'Carter, Miss. Lucile Polk', 'female', 14.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
  577. "[438, 439, 0, 1, 'Fortune, Mr. Mark', 'male', 64.0, 1, 4, '19950', 263.0, 'C23 C25 C27', 'S']\n",
  578. "[445, 446, 1, 1, 'Dodge, Master. Washington', 'male', 4.0, 0, 2, '33638', 81.8583, 'A34', 'S']\n",
  579. "[447, 448, 1, 1, 'Seward, Mr. Frederic Kimber', 'male', 34.0, 0, 0, '113794', 26.55, nan, 'S']\n",
  580. "[449, 450, 1, 1, 'Peuchen, Major. Arthur Godfrey', 'male', 52.0, 0, 0, '113786', 30.5, 'C104', 'S']\n",
  581. "[452, 453, 0, 1, 'Foreman, Mr. Benjamin Laventall', 'male', 30.0, 0, 0, '113051', 27.75, 'C111', 'C']\n",
  582. "[453, 454, 1, 1, 'Goldenberg, Mr. Samuel L', 'male', 49.0, 1, 0, '17453', 89.1042, 'C92', 'C']\n",
  583. "[456, 457, 0, 1, 'Millet, Mr. Francis Davis', 'male', 65.0, 0, 0, '13509', 26.55, 'E38', 'S']\n",
  584. "[457, 458, 1, 1, 'Kenyon, Mrs. Frederick R (Marion)', 'female', nan, 1, 0, '17464', 51.8625, 'D21', 'S']\n",
  585. "[460, 461, 1, 1, 'Anderson, Mr. Harry', 'male', 48.0, 0, 0, '19952', 26.55, 'E12', 'S']\n",
  586. "[462, 463, 0, 1, 'Gee, Mr. Arthur H', 'male', 47.0, 0, 0, '111320', 38.5, 'E63', 'S']\n",
  587. "[467, 468, 0, 1, 'Smart, Mr. John Montgomery', 'male', 56.0, 0, 0, '113792', 26.55, nan, 'S']\n",
  588. "[475, 476, 0, 1, 'Clifford, Mr. George Quincy', 'male', nan, 0, 0, '110465', 52.0, 'A14', 'S']\n",
  589. "[484, 485, 1, 1, 'Bishop, Mr. Dickinson H', 'male', 25.0, 1, 0, '11967', 91.0792, 'B49', 'C']\n",
  590. "[486, 487, 1, 1, 'Hoyt, Mrs. Frederick Maxfield (Jane Anne Forby)', 'female', 35.0, 1, 0, '19943', 90.0, 'C93', 'S']\n",
  591. "[487, 488, 0, 1, 'Kent, Mr. Edward Austin', 'male', 58.0, 0, 0, '11771', 29.7, 'B37', 'C']\n",
  592. "[492, 493, 0, 1, 'Molson, Mr. Harry Markland', 'male', 55.0, 0, 0, '113787', 30.5, 'C30', 'S']\n",
  593. "[493, 494, 0, 1, 'Artagaveytia, Mr. Ramon', 'male', 71.0, 0, 0, 'PC 17609', 49.5042, nan, 'C']\n",
  594. "[496, 497, 1, 1, 'Eustis, Miss. Elizabeth Mussey', 'female', 54.0, 1, 0, '36947', 78.2667, 'D20', 'C']\n",
  595. "[498, 499, 0, 1, 'Allison, Mrs. Hudson J C (Bessie Waldo Daniels)', 'female', 25.0, 1, 2, '113781', 151.55, 'C22 C26', 'S']\n",
  596. "[504, 505, 1, 1, 'Maioni, Miss. Roberta', 'female', 16.0, 0, 0, '110152', 86.5, 'B79', 'S']\n",
  597. "[505, 506, 0, 1, 'Penasco y Castellana, Mr. Victor de Satode', 'male', 18.0, 1, 0, 'PC 17758', 108.9, 'C65', 'C']\n",
  598. "[507, 508, 1, 1, 'Bradley, Mr. George (\"George Arthur Brayton\")', 'male', nan, 0, 0, '111427', 26.55, nan, 'S']\n",
  599. "[512, 513, 1, 1, 'McGough, Mr. James Robert', 'male', 36.0, 0, 0, 'PC 17473', 26.2875, 'E25', 'S']\n",
  600. "[513, 514, 1, 1, 'Rothschild, Mrs. Martin (Elizabeth L. Barrett)', 'female', 54.0, 1, 0, 'PC 17603', 59.4, nan, 'C']\n",
  601. "[515, 516, 0, 1, 'Walker, Mr. William Anderson', 'male', 47.0, 0, 0, '36967', 34.0208, 'D46', 'S']\n",
  602. "[520, 521, 1, 1, 'Perreault, Miss. Anne', 'female', 30.0, 0, 0, '12749', 93.5, 'B73', 'S']\n",
  603. "[523, 524, 1, 1, 'Hippach, Mrs. Louis Albert (Ida Sophia Fischer)', 'female', 44.0, 0, 1, '111361', 57.9792, 'B18', 'C']\n",
  604. "[527, 528, 0, 1, 'Farthing, Mr. John', 'male', nan, 0, 0, 'PC 17483', 221.7792, 'C95', 'S']\n",
  605. "[536, 537, 0, 1, 'Butt, Major. Archibald Willingham', 'male', 45.0, 0, 0, '113050', 26.55, 'B38', 'S']\n",
  606. "[537, 538, 1, 1, 'LeRoy, Miss. Bertha', 'female', 30.0, 0, 0, 'PC 17761', 106.425, nan, 'C']\n",
  607. "[539, 540, 1, 1, 'Frolicher, Miss. Hedwig Margaritha', 'female', 22.0, 0, 2, '13568', 49.5, 'B39', 'C']\n",
  608. "[540, 541, 1, 1, 'Crosby, Miss. Harriet R', 'female', 36.0, 0, 2, 'WE/P 5735', 71.0, 'B22', 'S']\n",
  609. "[544, 545, 0, 1, 'Douglas, Mr. Walter Donald', 'male', 50.0, 1, 0, 'PC 17761', 106.425, 'C86', 'C']\n",
  610. "[545, 546, 0, 1, 'Nicholson, Mr. Arthur Ernest', 'male', 64.0, 0, 0, '693', 26.0, nan, 'S']\n",
  611. "[550, 551, 1, 1, 'Thayer, Mr. John Borland Jr', 'male', 17.0, 0, 2, '17421', 110.8833, 'C70', 'C']\n",
  612. "[555, 556, 0, 1, 'Wright, Mr. George', 'male', 62.0, 0, 0, '113807', 26.55, nan, 'S']\n",
  613. "[556, 557, 1, 1, 'Duff Gordon, Lady. (Lucille Christiana Sutherland) (\"Mrs Morgan\")', 'female', 48.0, 1, 0, '11755', 39.6, 'A16', 'C']\n",
  614. "[557, 558, 0, 1, 'Robbins, Mr. Victor', 'male', nan, 0, 0, 'PC 17757', 227.525, nan, 'C']\n",
  615. "[558, 559, 1, 1, 'Taussig, Mrs. Emil (Tillie Mandelbaum)', 'female', 39.0, 1, 1, '110413', 79.65, 'E67', 'S']\n",
  616. "[571, 572, 1, 1, 'Appleton, Mrs. Edward Dale (Charlotte Lamson)', 'female', 53.0, 2, 0, '11769', 51.4792, 'C101', 'S']\n",
  617. "[572, 573, 1, 1, 'Flynn, Mr. John Irwin (\"Irving\")', 'male', 36.0, 0, 0, 'PC 17474', 26.3875, 'E25', 'S']\n",
  618. "[577, 578, 1, 1, 'Silvey, Mrs. William Baird (Alice Munger)', 'female', 39.0, 1, 0, '13507', 55.9, 'E44', 'S']\n",
  619. "[581, 582, 1, 1, 'Thayer, Mrs. John Borland (Marian Longstreth Morris)', 'female', 39.0, 1, 1, '17421', 110.8833, 'C68', 'C']\n",
  620. "[583, 584, 0, 1, 'Ross, Mr. John Hugo', 'male', 36.0, 0, 0, '13049', 40.125, 'A10', 'C']\n",
  621. "[585, 586, 1, 1, 'Taussig, Miss. Ruth', 'female', 18.0, 0, 2, '110413', 79.65, 'E68', 'S']\n",
  622. "[587, 588, 1, 1, 'Frolicher-Stehli, Mr. Maxmillian', 'male', 60.0, 1, 1, '13567', 79.2, 'B41', 'C']\n",
  623. "[591, 592, 1, 1, 'Stephenson, Mrs. Walter Bertram (Martha Eustis)', 'female', 52.0, 1, 0, '36947', 78.2667, 'D20', 'C']\n",
  624. "[599, 600, 1, 1, 'Duff Gordon, Sir. Cosmo Edmund (\"Mr Morgan\")', 'male', 49.0, 1, 0, 'PC 17485', 56.9292, 'A20', 'C']\n",
  625. "[602, 603, 0, 1, 'Harrington, Mr. Charles H', 'male', nan, 0, 0, '113796', 42.4, nan, 'S']\n",
  626. "[604, 605, 1, 1, 'Homer, Mr. Harry (\"Mr E Haven\")', 'male', 35.0, 0, 0, '111426', 26.55, nan, 'C']\n",
  627. "[607, 608, 1, 1, 'Daniel, Mr. Robert Williams', 'male', 27.0, 0, 0, '113804', 30.5, nan, 'S']\n",
  628. "[609, 610, 1, 1, 'Shutes, Miss. Elizabeth W', 'female', 40.0, 0, 0, 'PC 17582', 153.4625, 'C125', 'S']\n",
  629. "[621, 622, 1, 1, 'Kimball, Mr. Edwin Nelson Jr', 'male', 42.0, 1, 0, '11753', 52.5542, 'D19', 'S']\n",
  630. "[625, 626, 0, 1, 'Sutton, Mr. Frederick', 'male', 61.0, 0, 0, '36963', 32.3208, 'D50', 'S']\n",
  631. "[627, 628, 1, 1, 'Longley, Miss. Gretchen Fiske', 'female', 21.0, 0, 0, '13502', 77.9583, 'D9', 'S']\n",
  632. "[630, 631, 1, 1, 'Barkworth, Mr. Algernon Henry Wilson', 'male', 80.0, 0, 0, '27042', 30.0, 'A23', 'S']\n",
  633. "[632, 633, 1, 1, 'Stahelin-Maeglin, Dr. Max', 'male', 32.0, 0, 0, '13214', 30.5, 'B50', 'C']\n",
  634. "[633, 634, 0, 1, 'Parr, Mr. William Henry Marsh', 'male', nan, 0, 0, '112052', 0.0, nan, 'S']\n",
  635. "[641, 642, 1, 1, 'Sagesser, Mlle. Emma', 'female', 24.0, 0, 0, 'PC 17477', 69.3, 'B35', 'C']\n",
  636. "[645, 646, 1, 1, 'Harper, Mr. Henry Sleeper', 'male', 48.0, 1, 0, 'PC 17572', 76.7292, 'D33', 'C']\n",
  637. "[647, 648, 1, 1, 'Simonius-Blumer, Col. Oberst Alfons', 'male', 56.0, 0, 0, '13213', 35.5, 'A26', 'C']\n",
  638. "[659, 660, 0, 1, 'Newell, Mr. Arthur Webster', 'male', 58.0, 0, 2, '35273', 113.275, 'D48', 'C']\n",
  639. "[660, 661, 1, 1, 'Frauenthal, Dr. Henry William', 'male', 50.0, 2, 0, 'PC 17611', 133.65, nan, 'S']\n",
  640. "[662, 663, 0, 1, 'Colley, Mr. Edward Pomeroy', 'male', 47.0, 0, 0, '5727', 25.5875, 'E58', 'S']\n",
  641. "[669, 670, 1, 1, 'Taylor, Mrs. Elmer Zebley (Juliet Cummins Wright)', 'female', nan, 1, 0, '19996', 52.0, 'C126', 'S']\n",
  642. "[671, 672, 0, 1, 'Davidson, Mr. Thornton', 'male', 31.0, 1, 0, 'F.C. 12750', 52.0, 'B71', 'S']\n",
  643. "[679, 680, 1, 1, 'Cardeza, Mr. Thomas Drake Martinez', 'male', 36.0, 0, 1, 'PC 17755', 512.3292, 'B51 B53 B55', 'C']\n",
  644. "[681, 682, 1, 1, 'Hassab, Mr. Hammad', 'male', 27.0, 0, 0, 'PC 17572', 76.7292, 'D49', 'C']\n",
  645. "[689, 690, 1, 1, 'Madill, Miss. Georgette Alexandra', 'female', 15.0, 0, 1, '24160', 211.3375, 'B5', 'S']\n",
  646. "[690, 691, 1, 1, 'Dick, Mr. Albert Adrian', 'male', 31.0, 1, 0, '17474', 57.0, 'B20', 'S']\n",
  647. "[694, 695, 0, 1, 'Weir, Col. John', 'male', 60.0, 0, 0, '113800', 26.55, nan, 'S']\n",
  648. "[698, 699, 0, 1, 'Thayer, Mr. John Borland', 'male', 49.0, 1, 1, '17421', 110.8833, 'C68', 'C']\n",
  649. "[700, 701, 1, 1, 'Astor, Mrs. John Jacob (Madeleine Talmadge Force)', 'female', 18.0, 1, 0, 'PC 17757', 227.525, 'C62 C64', 'C']\n",
  650. "[701, 702, 1, 1, 'Silverthorne, Mr. Spencer Victor', 'male', 35.0, 0, 0, 'PC 17475', 26.2875, 'E24', 'S']\n",
  651. "[707, 708, 1, 1, 'Calderhead, Mr. Edward Pennington', 'male', 42.0, 0, 0, 'PC 17476', 26.2875, 'E24', 'S']\n",
  652. "[708, 709, 1, 1, 'Cleaver, Miss. Alice', 'female', 22.0, 0, 0, '113781', 151.55, nan, 'S']\n",
  653. "[710, 711, 1, 1, 'Mayne, Mlle. Berthe Antonine (\"Mrs de Villiers\")', 'female', 24.0, 0, 0, 'PC 17482', 49.5042, 'C90', 'C']\n",
  654. "[711, 712, 0, 1, 'Klaber, Mr. Herman', 'male', nan, 0, 0, '113028', 26.55, 'C124', 'S']\n",
  655. "[712, 713, 1, 1, 'Taylor, Mr. Elmer Zebley', 'male', 48.0, 1, 0, '19996', 52.0, 'C126', 'S']\n",
  656. "[716, 717, 1, 1, 'Endres, Miss. Caroline Louise', 'female', 38.0, 0, 0, 'PC 17757', 227.525, 'C45', 'C']\n",
  657. "[724, 725, 1, 1, 'Chambers, Mr. Norman Campbell', 'male', 27.0, 1, 0, '113806', 53.1, 'E8', 'S']\n",
  658. "[730, 731, 1, 1, 'Allen, Miss. Elisabeth Walton', 'female', 29.0, 0, 0, '24160', 211.3375, 'B5', 'S']\n",
  659. "[737, 738, 1, 1, 'Lesurer, Mr. Gustave J', 'male', 35.0, 0, 0, 'PC 17755', 512.3292, 'B101', 'C']\n",
  660. "[740, 741, 1, 1, 'Hawksford, Mr. Walter James', 'male', nan, 0, 0, '16988', 30.0, 'D45', 'S']\n",
  661. "[741, 742, 0, 1, 'Cavendish, Mr. Tyrell William', 'male', 36.0, 1, 0, '19877', 78.85, 'C46', 'S']\n",
  662. "[742, 743, 1, 1, 'Ryerson, Miss. Susan Parker \"Suzette\"', 'female', 21.0, 2, 2, 'PC 17608', 262.375, 'B57 B59 B63 B66', 'C']\n",
  663. "[745, 746, 0, 1, 'Crosby, Capt. Edward Gifford', 'male', 70.0, 1, 1, 'WE/P 5735', 71.0, 'B22', 'S']\n",
  664. "[748, 749, 0, 1, 'Marvin, Mr. Daniel Warner', 'male', 19.0, 1, 0, '113773', 53.1, 'D30', 'S']\n",
  665. "[759, 760, 1, 1, 'Rothes, the Countess. of (Lucy Noel Martha Dyer-Edwards)', 'female', 33.0, 0, 0, '110152', 86.5, 'B77', 'S']\n",
  666. "[763, 764, 1, 1, 'Carter, Mrs. William Ernest (Lucile Polk)', 'female', 36.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
  667. "[765, 766, 1, 1, 'Hogeboom, Mrs. John C (Anna Andrews)', 'female', 51.0, 1, 0, '13502', 77.9583, 'D11', 'S']\n",
  668. "[766, 767, 0, 1, 'Brewe, Dr. Arthur Jackson', 'male', nan, 0, 0, '112379', 39.6, nan, 'C']\n",
  669. "[779, 780, 1, 1, 'Robert, Mrs. Edward Scott (Elisabeth Walton McMillan)', 'female', 43.0, 0, 1, '24160', 211.3375, 'B3', 'S']\n",
  670. "[781, 782, 1, 1, 'Dick, Mrs. Albert Adrian (Vera Gillespie)', 'female', 17.0, 1, 0, '17474', 57.0, 'B20', 'S']\n",
  671. "[782, 783, 0, 1, 'Long, Mr. Milton Clyde', 'male', 29.0, 0, 0, '113501', 30.0, 'D6', 'S']\n",
  672. "[789, 790, 0, 1, 'Guggenheim, Mr. Benjamin', 'male', 46.0, 0, 0, 'PC 17593', 79.2, 'B82 B84', 'C']\n",
  673. "[793, 794, 0, 1, 'Hoyt, Mr. William Fisher', 'male', nan, 0, 0, 'PC 17600', 30.6958, nan, 'C']\n",
  674. "[796, 797, 1, 1, 'Leader, Dr. Alice (Farnham)', 'female', 49.0, 0, 0, '17465', 25.9292, 'D17', 'S']\n",
  675. "[802, 803, 1, 1, 'Carter, Master. William Thornton II', 'male', 11.0, 1, 2, '113760', 120.0, 'B96 B98', 'S']\n",
  676. "[806, 807, 0, 1, 'Andrews, Mr. Thomas Jr', 'male', 39.0, 0, 0, '112050', 0.0, 'A36', 'S']\n",
  677. "[809, 810, 1, 1, 'Chambers, Mrs. Norman Campbell (Bertha Griggs)', 'female', 33.0, 1, 0, '113806', 53.1, 'E8', 'S']\n",
  678. "[815, 816, 0, 1, 'Fry, Mr. Richard', 'male', nan, 0, 0, '112058', 0.0, 'B102', 'S']\n",
  679. "[820, 821, 1, 1, 'Hays, Mrs. Charles Melville (Clara Jennings Gregg)', 'female', 52.0, 1, 1, '12749', 93.5, 'B69', 'S']\n",
  680. "[822, 823, 0, 1, 'Reuchlin, Jonkheer. John George', 'male', 38.0, 0, 0, '19972', 0.0, nan, 'S']\n",
  681. "[829, 830, 1, 1, 'Stone, Mrs. George Nelson (Martha Evelyn)', 'female', 62.0, 0, 0, '113572', 80.0, 'B28', nan]\n",
  682. "[835, 836, 1, 1, 'Compton, Miss. Sara Rebecca', 'female', 39.0, 1, 1, 'PC 17756', 83.1583, 'E49', 'C']\n",
  683. "[839, 840, 1, 1, 'Marechal, Mr. Pierre', 'male', nan, 0, 0, '11774', 29.7, 'C47', 'C']\n",
  684. "[842, 843, 1, 1, 'Serepeca, Miss. Augusta', 'female', 30.0, 0, 0, '113798', 31.0, nan, 'C']\n",
  685. "[849, 850, 1, 1, 'Goldenberg, Mrs. Samuel L (Edwiga Grabowska)', 'female', nan, 1, 0, '17453', 89.1042, 'C92', 'C']\n",
  686. "[853, 854, 1, 1, 'Lines, Miss. Mary Conover', 'female', 16.0, 0, 1, 'PC 17592', 39.4, 'D28', 'S']\n",
  687. "[856, 857, 1, 1, 'Wick, Mrs. George Dennick (Mary Hitchcock)', 'female', 45.0, 1, 1, '36928', 164.8667, nan, 'S']\n",
  688. "[857, 858, 1, 1, 'Daly, Mr. Peter Denis ', 'male', 51.0, 0, 0, '113055', 26.55, 'E17', 'S']\n",
  689. "[862, 863, 1, 1, 'Swift, Mrs. Frederick Joel (Margaret Welles Barron)', 'female', 48.0, 0, 0, '17466', 25.9292, 'D17', 'S']\n",
  690. "[867, 868, 0, 1, 'Roebling, Mr. Washington Augustus II', 'male', 31.0, 0, 0, 'PC 17590', 50.4958, 'A24', 'S']\n",
  691. "[871, 872, 1, 1, 'Beckwith, Mrs. Richard Leonard (Sallie Monypeny)', 'female', 47.0, 1, 1, '11751', 52.5542, 'D35', 'S']\n",
  692. "[872, 873, 0, 1, 'Carlsson, Mr. Frans Olof', 'male', 33.0, 0, 0, '695', 5.0, 'B51 B53 B55', 'S']\n",
  693. "[879, 880, 1, 1, 'Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)', 'female', 56.0, 0, 1, '11767', 83.1583, 'C50', 'C']\n",
  694. "[887, 888, 1, 1, 'Graham, Miss. Margaret Edith', 'female', 19.0, 0, 0, '112053', 30.0, 'B42', 'S']\n",
  695. "[889, 890, 1, 1, 'Behr, Mr. Karl Howell', 'male', 26.0, 0, 0, '111369', 30.0, 'C148', 'C']\n"
  696. ]
  697. }
  698. ],
  699. "source": [
  700. "# dataframe_to_rowsを用いるとデータフレームを配列形式に変換してくれます。\n",
  701. "for row in dataframe_to_rows(df) :\n",
  702. " print(row)"
  703. ]
  704. },
  705. {
  706. "cell_type": "markdown",
  707. "metadata": {},
  708. "source": [
  709. "#### *それではappendを用いて、Pclass1のシートにデータフレームの値を記述していきましょう!*"
  710. ]
  711. },
  712. {
  713. "cell_type": "code",
  714. "execution_count": 45,
  715. "metadata": {
  716. "collapsed": true
  717. },
  718. "outputs": [],
  719. "source": [
  720. "# データフレームからExcelへ\n",
  721. "for row in dataframe_to_rows(df) :\n",
  722. " ws.append(row)\n",
  723. "\n",
  724. "# Excelに保存をします。\n",
  725. "wb.save(excel_file)"
  726. ]
  727. },
  728. {
  729. "cell_type": "code",
  730. "execution_count": null,
  731. "metadata": {
  732. "collapsed": true
  733. },
  734. "outputs": [],
  735. "source": []
  736. }
  737. ],
  738. "metadata": {
  739. "kernelspec": {
  740. "display_name": "Python 3",
  741. "language": "python",
  742. "name": "python3"
  743. },
  744. "language_info": {
  745. "codemirror_mode": {
  746. "name": "ipython",
  747. "version": 3
  748. },
  749. "file_extension": ".py",
  750. "mimetype": "text/x-python",
  751. "name": "python",
  752. "nbconvert_exporter": "python",
  753. "pygments_lexer": "ipython3",
  754. "version": "3.6.1"
  755. }
  756. },
  757. "nbformat": 4,
  758. "nbformat_minor": 2
  759. }
Add Comment
Please, Sign In to add comment