Skip to content

Commit

Permalink
updating sql I db
Browse files Browse the repository at this point in the history
  • Loading branch information
ishani07 committed Apr 3, 2024
1 parent 912627d commit e2a2ae3
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 189 deletions.
16 changes: 8 additions & 8 deletions docs/gradient_descent/gradient_descent.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 35 additions & 35 deletions docs/pandas_2/pandas_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -1650,12 +1650,12 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">366772</td>
<td data-quarto-table-cell-role="th">291690</td>
<td>CA</td>
<td>M</td>
<td>2008</td>
<td>Neeraj</td>
<td>5</td>
<td>1976</td>
<td>Devin</td>
<td>72</td>
</tr>
</tbody>
</table>
Expand All @@ -1682,34 +1682,34 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">167084</td>
<td>2004</td>
<td>Vicki</td>
<td data-quarto-table-cell-role="th">403504</td>
<td>2021</td>
<td>Abhiram</td>
<td>8</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">210217</td>
<td>2015</td>
<td>Mabel</td>
<td>63</td>
<td data-quarto-table-cell-role="th">129477</td>
<td>1994</td>
<td>Cheri</td>
<td>11</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">262294</td>
<td>1950</td>
<td>Quentin</td>
<td>5</td>
<td data-quarto-table-cell-role="th">356274</td>
<td>2005</td>
<td>Reyes</td>
<td>23</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">198220</td>
<td>2012</td>
<td>Vienna</td>
<td>55</td>
<td data-quarto-table-cell-role="th">275317</td>
<td>1963</td>
<td>Rolf</td>
<td>18</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">79888</td>
<td>1978</td>
<td>Letisha</td>
<td>8</td>
<td data-quarto-table-cell-role="th">387880</td>
<td>2016</td>
<td>Ben</td>
<td>55</td>
</tr>
</tbody>
</table>
Expand All @@ -1735,28 +1735,28 @@ <h3 data-number="3.3.4" class="anchored" data-anchor-id="sample"><span class="he
</thead>
<tbody>
<tr class="odd">
<td data-quarto-table-cell-role="th">151306</td>
<td data-quarto-table-cell-role="th">342715</td>
<td>2000</td>
<td>Janina</td>
<td>9</td>
<td>Darren</td>
<td>139</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">150540</td>
<td data-quarto-table-cell-role="th">149156</td>
<td>2000</td>
<td>Abrianna</td>
<td>16</td>
<td>Trinity</td>
<td>481</td>
</tr>
<tr class="odd">
<td data-quarto-table-cell-role="th">152423</td>
<td data-quarto-table-cell-role="th">343955</td>
<td>2000</td>
<td>Deven</td>
<td>5</td>
<td>Rajan</td>
<td>9</td>
</tr>
<tr class="even">
<td data-quarto-table-cell-role="th">344406</td>
<td data-quarto-table-cell-role="th">151213</td>
<td>2000</td>
<td>Chadwick</td>
<td>6</td>
<td>Tasha</td>
<td>10</td>
</tr>
</tbody>
</table>
Expand Down
14 changes: 7 additions & 7 deletions docs/pandas_3/pandas_3.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/regex/regex.html
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ <h4 data-number="6.2.1.2" class="anchored" data-anchor-id="canonicalization-with
<span id="cb6-13"><a href="#cb6-13" aria-hidden="true" tabindex="-1"></a>county_and_state[<span class="st">'clean_county_pandas'</span>] <span class="op">=</span> canonicalize_county_series(county_and_state[<span class="st">'County'</span>])</span>
<span id="cb6-14"><a href="#cb6-14" aria-hidden="true" tabindex="-1"></a>display(county_and_pop), display(county_and_state)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_49929/2523629438.py:3: FutureWarning:
<pre><code>/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_59489/2523629438.py:3: FutureWarning:

The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.

/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_49929/2523629438.py:3: FutureWarning:
/var/folders/7t/zbwy02ts2m7cn64fvwjqb8xw0000gp/T/ipykernel_59489/2523629438.py:3: FutureWarning:

The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.
</code></pre>
Expand Down
4 changes: 2 additions & 2 deletions docs/sampling/sampling.html
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ <h4 data-number="9.3.3.3" class="anchored" data-anchor-id="simple-random-sample"
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>random_sample <span class="op">=</span> movie.sample(n, replace <span class="op">=</span> <span class="va">False</span>) <span class="co">## By default, replace = False</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>np.mean(random_sample[<span class="st">"barbie"</span>])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<pre><code>0.5296914823759864</code></pre>
<pre><code>0.530662556066289</code></pre>
</div>
</div>
<p>This is very close to the actual vote of 0.5302792307692308!</p>
Expand All @@ -722,7 +722,7 @@ <h4 data-number="9.3.3.3" class="anchored" data-anchor-id="simple-random-sample"
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a>Markdown(<span class="ss">f"**Actual** = </span><span class="sc">{</span>actual_barbie<span class="sc">:.4f}</span><span class="ss">, **Sample** = </span><span class="sc">{</span>sample_barbie<span class="sc">:.4f}</span><span class="ss">, "</span></span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a> <span class="ss">f"**Err** = </span><span class="sc">{</span><span class="dv">100</span><span class="op">*</span>err<span class="sc">:.2f}</span><span class="ss">%."</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display" data-execution_count="10">
<p><strong>Actual</strong> = 0.5303, <strong>Sample</strong> = 0.5337, <strong>Err</strong> = 0.65%.</p>
<p><strong>Actual</strong> = 0.5303, <strong>Sample</strong> = 0.5487, <strong>Err</strong> = 3.48%.</p>
</div>
</div>
<p>We’ll learn how to choose this number when we (re)learn the Central Limit Theorem later in the semester.</p>
Expand Down
Binary file modified docs/sampling/sampling_files/figure-html/cell-13-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/sampling/sampling_files/figure-html/cell-15-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 31 additions & 38 deletions docs/sql_I/sql_I.html
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ <h2 data-number="20.2" class="anchored" data-anchor-id="intro-to-sql"><span clas
<p>For the purposes of Data 100, we use SQLite or DuckDB. SQLite is an easy-to-use library that allows users to directly manipulate a database file or an in-memory database with a simplified version of SQL. It’s commonly used to store data for small apps on mobile devices and is optimized for simplicity and speed of simple data tasks. DuckDB is an easy-to-use library that lets you directly manipulate a database file, collection of table formatted files (e.g., CSV), or in-memory <code>pandas</code> <code>DataFrame</code>s using a more complete version of SQL. It’s optimized for simplicity and speed of advanced data analysis tasks and is becoming increasingly popular for data analysis tasks on large datasets.</p>
<p>It is important to reiterate that SQL is an entirely different language from Python. However, Python <em>does</em> have special engines that allow us to run SQL code in a Jupyter notebook. While this is typically not how SQL is used outside of an educational setting, we will use this workflow to illustrate how SQL queries are constructed using the tools we’ve already worked with this semester. You will learn more about how to run SQL queries in Jupyter in Lab 10 and Homework 10.</p>
<p>The syntax below will seem unfamiliar to you; for now, just focus on understanding the output displayed. We will clarify the SQL code in a bit.</p>
<p>To start, we’ll look at a database called <code>basic_examples.db</code> and connect to it using SQLite.</p>
<p>To start, we’ll look at a database called <code>example_duck.db</code> and connect to it using SQLite.</p>
<div class="cell" data-vscode="{&quot;languageId&quot;:&quot;python&quot;}" data-execution_count="1">
<details>
<summary>Code</summary>
Expand All @@ -380,7 +380,7 @@ <h2 data-number="20.2" class="anchored" data-anchor-id="intro-to-sql"><span clas
</div>
<div class="cell" data-vscode="{&quot;languageId&quot;:&quot;python&quot;}" data-execution_count="3">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Connect to the database</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>sql duckdb:<span class="op">///</span>data<span class="op">/</span>basic_examples.db <span class="op">--</span>alias duck</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>sql duckdb:<span class="op">///</span>data<span class="op">/</span>example_duck.db <span class="op">--</span>alias duck</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Now that we’re connected, let’s make some queries!</p>
<div class="cell" data-vscode="{&quot;languageId&quot;:&quot;python&quot;}" data-execution_count="4">
Expand Down Expand Up @@ -461,31 +461,24 @@ <h2 data-number="20.3" class="anchored" data-anchor-id="tables-and-schema"><span
<tbody>
<tr class="odd">
<td>table</td>
<td>sqlite_sequence</td>
<td>sqlite_sequence</td>
<td>dish</td>
<td>dish</td>
<td>0</td>
<td>CREATE TABLE sqlite_sequence("name" BLOB, seq BLOB);</td>
<td>CREATE TABLE dish("name" VARCHAR PRIMARY KEY, "type" VARCHAR, "cost" INTEGER, CHECK(("cost" &gt;= 0)));</td>
</tr>
<tr class="even">
<td>table</td>
<td>Dragon</td>
<td>Dragon</td>
<td>dragon</td>
<td>dragon</td>
<td>0</td>
<td>CREATE TABLE Dragon("name" VARCHAR PRIMARY KEY, "year" BIGINT, cute BIGINT);</td>
<td>CREATE TABLE dragon("name" VARCHAR PRIMARY KEY, "year" INTEGER, cute INTEGER, CHECK(("year" &gt;= 2000)));</td>
</tr>
<tr class="odd">
<td>table</td>
<td>Dish</td>
<td>Dish</td>
<td>scene</td>
<td>scene</td>
<td>0</td>
<td>CREATE TABLE Dish("name" VARCHAR PRIMARY KEY, "type" VARCHAR, "cost" BIGINT);</td>
</tr>
<tr class="even">
<td>table</td>
<td>Scene</td>
<td>Scene</td>
<td>0</td>
<td>CREATE TABLE Scene(id BIGINT PRIMARY KEY, biome VARCHAR NOT NULL, city VARCHAR NOT NULL, visitors BIGINT, created_at TIMESTAMP DEFAULT(datetime('now')));</td>
<td>CREATE TABLE scene(id INTEGER PRIMARY KEY, biome VARCHAR NOT NULL, city VARCHAR NOT NULL, visitors INTEGER, created_at TIMESTAMP DEFAULT(current_date()), CHECK((visitors &gt;= 0)));</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -720,10 +713,10 @@ <h4 data-number="20.4.1.3" class="anchored" data-anchor-id="uniqueness-with-dist
</thead>
<tbody>
<tr class="odd">
<td>2011</td>
<td>2010</td>
</tr>
<tr class="even">
<td>2010</td>
<td>2011</td>
</tr>
<tr class="odd">
<td>2019</td>
Expand Down Expand Up @@ -1204,13 +1197,13 @@ <h2 data-number="20.5" class="anchored" data-anchor-id="aggregating-with-group-b
</thead>
<tbody>
<tr class="odd">
<td>entree</td>
<td>30</td>
</tr>
<tr class="even">
<td>appetizer</td>
<td>12</td>
</tr>
<tr class="even">
<td>entree</td>
<td>30</td>
</tr>
<tr class="odd">
<td>dessert</td>
<td>5</td>
Expand Down Expand Up @@ -1259,17 +1252,17 @@ <h2 data-number="20.5" class="anchored" data-anchor-id="aggregating-with-group-b
<td>taco</td>
</tr>
<tr class="even">
<td>appetizer</td>
<td>12</td>
<td>4</td>
<td>potsticker</td>
</tr>
<tr class="odd">
<td>dessert</td>
<td>5</td>
<td>5</td>
<td>ice cream</td>
</tr>
<tr class="odd">
<td>appetizer</td>
<td>12</td>
<td>4</td>
<td>potsticker</td>
</tr>
</tbody>
</table>

Expand All @@ -1295,11 +1288,11 @@ <h2 data-number="20.5" class="anchored" data-anchor-id="aggregating-with-group-b
</thead>
<tbody>
<tr class="odd">
<td>2011</td>
<td>2010</td>
<td>2</td>
</tr>
<tr class="even">
<td>2010</td>
<td>2011</td>
<td>2</td>
</tr>
<tr class="odd">
Expand Down Expand Up @@ -1331,13 +1324,13 @@ <h2 data-number="20.5" class="anchored" data-anchor-id="aggregating-with-group-b
</thead>
<tbody>
<tr class="odd">
<td>2011</td>
<td>1</td>
</tr>
<tr class="even">
<td>2010</td>
<td>2</td>
</tr>
<tr class="even">
<td>2011</td>
<td>1</td>
</tr>
<tr class="odd">
<td>2019</td>
<td>1</td>
Expand Down Expand Up @@ -1728,7 +1721,7 @@ <h2 data-number="20.6" class="anchored" data-anchor-id="summary"><span class="he
<span id="cb32-56"><a href="#cb32-56" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-57"><a href="#cb32-57" aria-hidden="true" tabindex="-1"></a>The syntax below will seem unfamiliar to you; for now, just focus on understanding the output displayed. We will clarify the SQL code in a bit.</span>
<span id="cb32-58"><a href="#cb32-58" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-59"><a href="#cb32-59" aria-hidden="true" tabindex="-1"></a>To start, we'll look at a database called <span class="in">`basic_examples.db`</span> and connect to it using SQLite.</span>
<span id="cb32-59"><a href="#cb32-59" aria-hidden="true" tabindex="-1"></a>To start, we'll look at a database called <span class="in">`example_duck.db`</span> and connect to it using SQLite.</span>
<span id="cb32-60"><a href="#cb32-60" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-63"><a href="#cb32-63" aria-hidden="true" tabindex="-1"></a><span class="in">```{python}</span></span>
<span id="cb32-64"><a href="#cb32-64" aria-hidden="true" tabindex="-1"></a><span class="co">#| code-fold: true</span></span>
Expand All @@ -1747,7 +1740,7 @@ <h2 data-number="20.6" class="anchored" data-anchor-id="summary"><span class="he
<span id="cb32-81"><a href="#cb32-81" aria-hidden="true" tabindex="-1"></a><span class="in">```{python}</span></span>
<span id="cb32-82"><a href="#cb32-82" aria-hidden="true" tabindex="-1"></a><span class="co">#| vscode: {languageId: python}</span></span>
<span id="cb32-83"><a href="#cb32-83" aria-hidden="true" tabindex="-1"></a><span class="co"># Connect to the database</span></span>
<span id="cb32-84"><a href="#cb32-84" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>sql duckdb:<span class="op">///</span>data<span class="op">/</span>basic_examples.db <span class="op">--</span>alias duck</span>
<span id="cb32-84"><a href="#cb32-84" aria-hidden="true" tabindex="-1"></a><span class="op">%</span>sql duckdb:<span class="op">///</span>data<span class="op">/</span>example_duck.db <span class="op">--</span>alias duck</span>
<span id="cb32-85"><a href="#cb32-85" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span>
<span id="cb32-86"><a href="#cb32-86" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-87"><a href="#cb32-87" aria-hidden="true" tabindex="-1"></a>Now that we’re connected, let’s make some queries!</span>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2024.3.3) 2 APR 2024 17:00
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex 2024.3.3) 2 APR 2024 22:01
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
Expand Down
Binary file modified index.pdf
Binary file not shown.
Loading

0 comments on commit e2a2ae3

Please sign in to comment.