Skip to content

Commit d5ca501

Browse files
committed
updated 2nd ed book code
1 parent c9a5078 commit d5ca501

File tree

51 files changed

+284348
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+284348
-2
lines changed

New-Second-Edition/Ch01 - Natural Language Processing Basics/Ch01 - Natural Language Processing Basics.ipynb

Lines changed: 953 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stderr",
10+
"output_type": "stream",
11+
"text": [
12+
"Python 3.5.2 :: Anaconda custom (64-bit)\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"!python --version"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 2,
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"name": "stdout",
27+
"output_type": "stream",
28+
"text": [
29+
"Welcome to Python\n"
30+
]
31+
}
32+
],
33+
"source": [
34+
"print('Welcome to Python')"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 3,
40+
"metadata": {},
41+
"outputs": [
42+
{
43+
"name": "stdout",
44+
"output_type": "stream",
45+
"text": [
46+
"pandas==0.20.3\n"
47+
]
48+
},
49+
{
50+
"name": "stderr",
51+
"output_type": "stream",
52+
"text": [
53+
"You are using pip version 9.0.1, however version 10.0.1 is available.\n",
54+
"You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"!pip freeze | grep pandas"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 4,
65+
"metadata": {},
66+
"outputs": [
67+
{
68+
"name": "stdout",
69+
"output_type": "stream",
70+
"text": [
71+
"Requirement already satisfied: pandas in c:\\program files\\anaconda3\\lib\\site-packages\n",
72+
"Requirement already satisfied: python-dateutil>=2 in c:\\program files\\anaconda3\\lib\\site-packages (from pandas)\n",
73+
"Requirement already satisfied: pytz>=2011k in c:\\program files\\anaconda3\\lib\\site-packages (from pandas)\n",
74+
"Requirement already satisfied: numpy>=1.7.0 in c:\\program files\\anaconda3\\lib\\site-packages (from pandas)\n",
75+
"Requirement already satisfied: six>=1.5 in c:\\program files\\anaconda3\\lib\\site-packages (from python-dateutil>=2->pandas)\n"
76+
]
77+
},
78+
{
79+
"name": "stderr",
80+
"output_type": "stream",
81+
"text": [
82+
"You are using pip version 9.0.1, however version 10.0.1 is available.\n",
83+
"You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
84+
]
85+
}
86+
],
87+
"source": [
88+
"!pip install pandas"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": 4,
94+
"metadata": {},
95+
"outputs": [
96+
{
97+
"name": "stdout",
98+
"output_type": "stream",
99+
"text": [
100+
"Collecting pandas\n",
101+
" Downloading https://files.pythonhosted.org/packages/24/f1/bbe61db3ab675ae612d5261e69cff05f1ff0a7638469a9faa1c9cdc1dcd5/pandas-0.23.3-cp35-cp35m-win_amd64.whl (7.6MB)\n",
102+
"Collecting python-dateutil>=2.5.0 (from pandas)\n",
103+
" Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)\n",
104+
"Collecting numpy>=1.9.0 (from pandas)\n",
105+
" Downloading https://files.pythonhosted.org/packages/f3/71/94628784c3f07d4bc0dd38f8753e3f751d66cfd5a6823591179608c27f09/numpy-1.14.5-cp35-none-win_amd64.whl (13.4MB)\n",
106+
"Collecting pytz>=2011k (from pandas)\n",
107+
" Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)\n",
108+
"Collecting six>=1.5 (from python-dateutil>=2.5.0->pandas)\n",
109+
" Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl\n",
110+
"Installing collected packages: six, python-dateutil, numpy, pytz, pandas\n",
111+
" Found existing installation: six 1.10.0\n",
112+
" Uninstalling six-1.10.0:\n",
113+
" Successfully uninstalled six-1.10.0\n",
114+
" Found existing installation: python-dateutil 2.5.3\n",
115+
" Uninstalling python-dateutil-2.5.3:\n",
116+
" Successfully uninstalled python-dateutil-2.5.3\n",
117+
" Found existing installation: numpy 1.14.0\n",
118+
" Uninstalling numpy-1.14.0:\n"
119+
]
120+
},
121+
{
122+
"name": "stderr",
123+
"output_type": "stream",
124+
"text": [
125+
" DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.\n",
126+
"Exception:\n",
127+
"Traceback (most recent call last):\n",
128+
" File \"c:\\program files\\anaconda3\\lib\\shutil.py\", line 538, in move\n",
129+
" os.rename(src, real_dst)\n",
130+
"PermissionError: [WinError 5] Access is denied: 'c:\\\\program files\\\\anaconda3\\\\lib\\\\site-packages\\\\numpy-1.14.0.dist-info\\\\description.rst' -> 'C:\\\\Users\\\\DIP~1.DIP\\\\AppData\\\\Local\\\\Temp\\\\pip-bz4bun3s-uninstall\\\\program files\\\\anaconda3\\\\lib\\\\site-packages\\\\numpy-1.14.0.dist-info\\\\description.rst'\n",
131+
"\n",
132+
"During handling of the above exception, another exception occurred:\n",
133+
"\n",
134+
"Traceback (most recent call last):\n",
135+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\basecommand.py\", line 215, in main\n",
136+
" status = self.run(options, args)\n",
137+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\commands\\install.py\", line 342, in run\n",
138+
" prefix=options.prefix_path,\n",
139+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\req\\req_set.py\", line 778, in install\n",
140+
" requirement.uninstall(auto_confirm=True)\n",
141+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\req\\req_install.py\", line 754, in uninstall\n",
142+
" paths_to_remove.remove(auto_confirm)\n",
143+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\req\\req_uninstall.py\", line 115, in remove\n",
144+
" renames(path, new_path)\n",
145+
" File \"c:\\program files\\anaconda3\\lib\\site-packages\\pip\\utils\\__init__.py\", line 267, in renames\n",
146+
" shutil.move(old, new)\n",
147+
" File \"c:\\program files\\anaconda3\\lib\\shutil.py\", line 553, in move\n",
148+
" os.unlink(src)\n",
149+
"PermissionError: [WinError 5] Access is denied: 'c:\\\\program files\\\\anaconda3\\\\lib\\\\site-packages\\\\numpy-1.14.0.dist-info\\\\description.rst'\n",
150+
"You are using pip version 9.0.1, however version 10.0.1 is available.\n",
151+
"You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
152+
]
153+
}
154+
],
155+
"source": [
156+
"!pip install pandas --upgrade"
157+
]
158+
},
159+
{
160+
"cell_type": "markdown",
161+
"metadata": {},
162+
"source": [
163+
"```\n",
164+
"\n",
165+
"C:\\> conda install pandas\n",
166+
"Solving environment: done\n",
167+
"\n",
168+
"## Package Plan ##\n",
169+
"\n",
170+
" environment location: C:\\Program Files\\Anaconda3\n",
171+
"\n",
172+
" added / updated specs:\n",
173+
" - pandas\n",
174+
"\n",
175+
"\n",
176+
"The following packages will be downloaded:\n",
177+
"\n",
178+
" package | build\n",
179+
" ---------------------------|-----------------\n",
180+
" pandas-0.23.3 | py35_0 8.6 MB conda-forge\n",
181+
"\n",
182+
"The following packages will be UPDATED:\n",
183+
"\n",
184+
" pandas: 0.20.3-py35_1 conda-forge --> 0.23.3-py35_0 conda-forge\n",
185+
"\n",
186+
"Proceed ([y]/n)? y\n",
187+
"\n",
188+
"\n",
189+
"Downloading and Extracting Packages\n",
190+
"pandas-0.23.3 | 8.6 MB | ########################################################### | 100%\n",
191+
"Preparing transaction: done\n",
192+
"Verifying transaction: done\n",
193+
"Executing transaction: done\n",
194+
"```"
195+
]
196+
},
197+
{
198+
"cell_type": "code",
199+
"execution_count": 5,
200+
"metadata": {},
201+
"outputs": [
202+
{
203+
"name": "stdout",
204+
"output_type": "stream",
205+
"text": [
206+
"pandas==0.23.3\n"
207+
]
208+
},
209+
{
210+
"name": "stderr",
211+
"output_type": "stream",
212+
"text": [
213+
"You are using pip version 9.0.1, however version 10.0.1 is available.\n",
214+
"You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
215+
]
216+
}
217+
],
218+
"source": [
219+
"!pip freeze | grep pandas"
220+
]
221+
},
222+
{
223+
"cell_type": "markdown",
224+
"metadata": {},
225+
"source": [
226+
"```\n",
227+
"E:\\>mkdir Apress\n",
228+
"E:\\>cd Apress\n",
229+
"E:\\Apress>pip install virtualenv\n",
230+
"Collecting virtualenv\n",
231+
"Installing collected packages: virtualenv\n",
232+
"Successfully installed virtualenv-16.0.0\n",
233+
"\n",
234+
"E:\\Apress>mkdir test_proj && chdir test_proj\n",
235+
"\n",
236+
"E:\\Apress\\test_proj>virtualenv venv\n",
237+
"Using base prefix 'c:\\\\program files\\\\anaconda3'\n",
238+
"New python executable in E:\\Apress\\test_proj\\venv\\Scripts\\python.exe\n",
239+
"Installing setuptools, pip, wheel...done.\n",
240+
"\n",
241+
"E:\\Apress\\test_proj>echo 'This is Global System Python'\n",
242+
"'This is Global System Python'\n",
243+
"\n",
244+
"E:\\Apress\\test_proj>pip freeze | grep pandas\n",
245+
"pandas==0.23.3\n",
246+
"\n",
247+
"\n",
248+
"\n",
249+
"E:\\Apress\\test_proj>venv\\Scripts\\activate\n",
250+
"\n",
251+
"(venv) E:\\Apress\\test_proj>echo 'This is VirtualEnv Python'\n",
252+
"'This is VirtualEnv Python'\n",
253+
"\n",
254+
"(venv) E:\\Apress\\test_proj>pip install pandas==0.21.0\n",
255+
"Collecting pandas==0.21.0\n",
256+
" 100% |################################| 9.0MB 310kB/s\n",
257+
"Collecting pytz>=2011k (from pandas==0.21.0)\n",
258+
"Collecting python-dateutil>=2 (from pandas==0.21.0)\n",
259+
"Collecting numpy>=1.9.0 (from pandas==0.21.0)\n",
260+
"Collecting six>=1.5 (from python-dateutil>=2->pandas==0.21.0)\n",
261+
"\n",
262+
"Installing collected packages: pytz, six, python-dateutil, numpy, pandas\n",
263+
"Successfully installed numpy-1.14.5 pandas-0.21.0 python-dateutil-2.7.3 pytz-2018.5 six-1.11.0\n",
264+
"\n",
265+
"(venv) E:\\Apress\\test_proj>pip freeze | grep pandas\n",
266+
"pandas==0.21.0\n",
267+
"\n",
268+
"(venv) E:\\Apress\\test_proj>venv\\Scripts\\deactivate\n",
269+
"E:\\Apress\\test_proj>pip freeze | grep pandas\n",
270+
"pandas==0.23.3\n",
271+
"```\n"
272+
]
273+
},
274+
{
275+
"cell_type": "markdown",
276+
"metadata": {},
277+
"source": [
278+
"http://docs.python-guide.org/en/latest/dev/virtualenvs/"
279+
]
280+
}
281+
],
282+
"metadata": {
283+
"anaconda-cloud": {},
284+
"kernelspec": {
285+
"display_name": "Python 3",
286+
"language": "python",
287+
"name": "python3"
288+
},
289+
"language_info": {
290+
"codemirror_mode": {
291+
"name": "ipython",
292+
"version": 3
293+
},
294+
"file_extension": ".py",
295+
"mimetype": "text/x-python",
296+
"name": "python",
297+
"nbconvert_exporter": "python",
298+
"pygments_lexer": "ipython3",
299+
"version": "3.6.5"
300+
}
301+
},
302+
"nbformat": 4,
303+
"nbformat_minor": 2
304+
}

0 commit comments

Comments
 (0)