Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d471a2e

Browse files
committed
requirements
1 parent e24f6e0 commit d471a2e

File tree

33 files changed

+21520
-0
lines changed

33 files changed

+21520
-0
lines changed

‎Chapter01/DataPrep_Titanic.ipynb‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import numpy as np\n",
10+
"import pandas as pd"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 2,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"def get_first_cabin(row):\n",
20+
" try:\n",
21+
" return row.split()[0]\n",
22+
" except:\n",
23+
" return np.nan "
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": 3,
29+
"metadata": {},
30+
"outputs": [],
31+
"source": [
32+
"data = pd.read_csv('https://www.openml.org/data/get_csv/16826755/phpMYEkMl')\n",
33+
"data = data.replace('?', np.nan)\n",
34+
"data['cabin'] = data['cabin'].apply(get_first_cabin)\n",
35+
"data.to_csv('titanic.csv', index=False)"
36+
]
37+
}
38+
],
39+
"metadata": {
40+
"kernelspec": {
41+
"display_name": "feml",
42+
"language": "python",
43+
"name": "feml"
44+
},
45+
"language_info": {
46+
"codemirror_mode": {
47+
"name": "ipython",
48+
"version": 3
49+
},
50+
"file_extension": ".py",
51+
"mimetype": "text/x-python",
52+
"name": "python",
53+
"nbconvert_exporter": "python",
54+
"pygments_lexer": "ipython3",
55+
"version": "3.7.3"
56+
},
57+
"toc": {
58+
"nav_menu": {},
59+
"number_sections": true,
60+
"sideBar": true,
61+
"skip_h1_title": false,
62+
"toc_cell": false,
63+
"toc_position": {},
64+
"toc_section_display": "block",
65+
"toc_window_display": false
66+
}
67+
},
68+
"nbformat": 4,
69+
"nbformat_minor": 2
70+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /