|
235 | 235 | <li class="toctree-l2"><a class="reference internal" href="../Chapter2/dataclasses.html">3.7. Data Classes</a></li>
|
236 | 236 | <li class="toctree-l2"><a class="reference internal" href="../Chapter2/typing.html">3.8. Typing</a></li>
|
237 | 237 | <li class="toctree-l2"><a class="reference internal" href="../Chapter2/pathlib.html">3.9. pathlib</a></li>
|
| 238 | +<li class="toctree-l2"><a class="reference internal" href="../Chapter2/pydantic.html">3.10. Pydantic</a></li> |
238 | 239 | </ul>
|
239 | 240 | </li>
|
240 | 241 | <li class="toctree-l1 has-children"><a class="reference internal" href="../Chapter3/Chapter3.html">4. Pandas</a><input class="toctree-checkbox" id="toctree-checkbox-4" name="toctree-checkbox-4" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-4"><i class="fa-solid fa-chevron-down"></i></label><ul>
|
@@ -523,6 +524,7 @@ <h2> Contents </h2>
|
523 | 524 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#debug-your-jupyter-notebook-s-code-with-snoop">8.1.8. Debug Your Jupyter Notebook’s Code with snoop</a></li>
|
524 | 525 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#integrate-jupyter-ai-for-seamless-code-creation-in-jupyter-notebook-and-lab">8.1.9. Integrate Jupyter AI for Seamless Code Creation in Jupyter Notebook and Lab</a></li>
|
525 | 526 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#testbook-write-clean-unit-tests-for-notebooks">8.1.10. testbook: Write Clean Unit Tests for Notebooks</a></li>
|
| 527 | +<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#navigating-and-managing-files-in-notebooks-top-magic-commands">8.1.11. Navigating and Managing Files in Notebooks: Top Magic Commands</a></li> |
526 | 528 | </ul>
|
527 | 529 | </nav>
|
528 | 530 | </div>
|
@@ -1166,6 +1168,54 @@ <h2><span class="section-number">8.1.10. </span>testbook: Write Clean Unit Tests
|
1166 | 1168 | </div>
|
1167 | 1169 | <p><a class="reference external" href="https://bit.ly/49dzOJ4">Link to testbook</a>.</p>
|
1168 | 1170 | </section>
|
| 1171 | +<section id="navigating-and-managing-files-in-notebooks-top-magic-commands"> |
| 1172 | +<h2><span class="section-number">8.1.11. </span>Navigating and Managing Files in Notebooks: Top Magic Commands<a class="headerlink" href="#navigating-and-managing-files-in-notebooks-top-magic-commands" title="Permalink to this heading">#</a></h2> |
| 1173 | +<p>To efficiently manage folders, navigate directories, write to files, and execute scripts directly from your notebook, consider using these four highly effective magic commands that simplify these tasks:</p> |
| 1174 | +<ul class="simple"> |
| 1175 | +<li><p><code class="docutils literal notranslate"><span class="pre">%mkdir</span></code>: Create new folders.</p></li> |
| 1176 | +<li><p><code class="docutils literal notranslate"><span class="pre">%cd</span></code>: Navigate through directories.</p></li> |
| 1177 | +<li><p><code class="docutils literal notranslate"><span class="pre">%%writefile</span></code>: Write content to files.</p></li> |
| 1178 | +<li><p><code class="docutils literal notranslate"><span class="pre">%run</span></code>: Run external Python scripts.</p></li> |
| 1179 | +</ul> |
| 1180 | +<div class="cell docutils container"> |
| 1181 | +<div class="cell_input docutils container"> |
| 1182 | +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="k">mkdir</span> my_project |
| 1183 | +<span class="o">%</span><span class="k">cd</span> my_project |
| 1184 | +</pre></div> |
| 1185 | +</div> |
| 1186 | +</div> |
| 1187 | +<div class="cell_output docutils container"> |
| 1188 | +<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/Users/khuyentran/book/Efficient_Python_tricks_and_tools_for_data_scientists/Chapter7/my_project |
| 1189 | +</pre></div> |
| 1190 | +</div> |
| 1191 | +</div> |
| 1192 | +</div> |
| 1193 | +<div class="cell docutils container"> |
| 1194 | +<div class="cell_input docutils container"> |
| 1195 | +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="o">%%writefile</span> process_data.py |
| 1196 | +<span class="nb">print</span><span class="p">(</span><span class="s2">"Processing data..."</span><span class="p">)</span> |
| 1197 | +</pre></div> |
| 1198 | +</div> |
| 1199 | +</div> |
| 1200 | +<div class="cell_output docutils container"> |
| 1201 | +<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Writing process_data.py |
| 1202 | +</pre></div> |
| 1203 | +</div> |
| 1204 | +</div> |
| 1205 | +</div> |
| 1206 | +<div class="cell docutils container"> |
| 1207 | +<div class="cell_input docutils container"> |
| 1208 | +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="o">%</span><span class="k">run</span> process_data.py |
| 1209 | +</pre></div> |
| 1210 | +</div> |
| 1211 | +</div> |
| 1212 | +<div class="cell_output docutils container"> |
| 1213 | +<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Processing data... |
| 1214 | +</pre></div> |
| 1215 | +</div> |
| 1216 | +</div> |
| 1217 | +</div> |
| 1218 | +</section> |
1169 | 1219 | </section>
|
1170 | 1220 |
|
1171 | 1221 | <script type="text/x-thebe-config">
|
@@ -1232,6 +1282,7 @@ <h2><span class="section-number">8.1.10. </span>testbook: Write Clean Unit Tests
|
1232 | 1282 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#debug-your-jupyter-notebook-s-code-with-snoop">8.1.8. Debug Your Jupyter Notebook’s Code with snoop</a></li>
|
1233 | 1283 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#integrate-jupyter-ai-for-seamless-code-creation-in-jupyter-notebook-and-lab">8.1.9. Integrate Jupyter AI for Seamless Code Creation in Jupyter Notebook and Lab</a></li>
|
1234 | 1284 | <li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#testbook-write-clean-unit-tests-for-notebooks">8.1.10. testbook: Write Clean Unit Tests for Notebooks</a></li>
|
| 1285 | +<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#navigating-and-managing-files-in-notebooks-top-magic-commands">8.1.11. Navigating and Managing Files in Notebooks: Top Magic Commands</a></li> |
1235 | 1286 | </ul>
|
1236 | 1287 | </nav></div>
|
1237 | 1288 |
|
|
0 commit comments