Skip to content

Commit 8b0ae2d

Browse files
committed
minor fixes to 04
1 parent 824f84a commit 8b0ae2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

04-representing-data-feature-engineering.ipynb

+5-4
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@
137137
"import os\n",
138138
"# The file has no headers naming the columns, so we pass header=None\n",
139139
"# and provide the column names explicitly in \"names\"\n",
140+
"adult_path = os.path.join(mglearn.datasets.DATA_PATH, \"adult.data\")\n",
140141
"data = pd.read_csv(\n",
141-
" os.path.join(mglearn.datasets.DATA_PATH, \"adult.data\"), header=None, index_col=False,\n",
142+
" adult_path, header=None, index_col=False,\n",
142143
" names=['age', 'workclass', 'fnlwgt', 'education', 'education-num',\n",
143144
" 'marital-status', 'occupation', 'relationship', 'race', 'gender',\n",
144145
" 'capital-gain', 'capital-loss', 'hours-per-week', 'native-country',\n",
@@ -1347,7 +1348,7 @@
13471348
}
13481349
],
13491350
"source": [
1350-
"plt.hist(np.log(X_train_log[:, 0] + 1), bins=25, color='gray')\n",
1351+
"plt.hist(X_train_log[:, 0], bins=25, color='gray')\n",
13511352
"plt.ylabel(\"Number of appearances\")\n",
13521353
"plt.xlabel(\"Value\")"
13531354
]
@@ -1787,8 +1788,8 @@
17871788
"source": [
17881789
"# extract the target values (number of rentals)\n",
17891790
"y = citibike.values\n",
1790-
"# convert the time to posixtime using \"%s\"\n",
1791-
"X = citibike.index.strftime(\"%s\").astype(\"int\").reshape(-1, 1)"
1791+
"# convert to POSIX time by dividing by 10**9\n",
1792+
"X = citibike.index.astype(\"int64\").values.reshape(-1, 1) // 10**9"
17921793
]
17931794
},
17941795
{

0 commit comments

Comments
 (0)