Skip to content

Commit

Permalink
Generated by commit e5a74eb, pushed by GitHub run 7258121089.
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 19, 2023
1 parent c5b7e65 commit 8595643
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 28 deletions.
Binary file modified _images/hist.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 _images/hist_binned.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 _images/hist_overlay.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 _images/plot.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 _images/scatter.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 _images/scatter_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 45 additions & 1 deletion _sources/tutorial.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,48 @@ Let's do the bootstrap test on the two categories.
Drawing Maps
------------
To come.
The main class in the maps module is the Map class. In this code we create a default Map. Maps can be displayed or converted to html.

.. ipython:: python
from datascience.maps import Map # import the Map class
default_map = Map() # generate a default Map
default_map.show() # display the Map
html = default_map.as_html() # generate the html
with open('map.html', 'w') as f: # make a file to store the html
f.write(html) # write the html to the file
The maps modules also allows you to make custom maps with markers, circles and regions.

.. ipython:: python
from datascience.maps import Map, Marker, Circle, Region # import the Map, Marker, Circle and Region class
# generates markers with custom sets of coordinates, colors and popups
marker1 = Marker(37.372, -121.758, color="green", popup="My green marker")
marker2 = Marker(37.572, -121.758, color="orange", popup="My orange marker")
# generates a circle with a custom set of coordinates, color and popup
circle = Circle(37.5, -122, color="red", area=1000, popup="My Circle")
# make a geojson object which is needed when making a region
geojson = {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [ # specifies the coordinates
[[-121,37],[-121.5,37],[-121.5,37.5],[-121,37.5],[-121,37]] # these coordinates make a rectangle
]
}
}
# make a region with your geojson object
region = Region(geojson)
# Initialize the map
custom_map = Map(features=[marker1, marker2, circle, region], # specifies the features
width=800, # specifies a custom width
height=600 # specifies a custom height
)
custom_map.show() # display the map
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>Welcome to datascience’s documentation!<a class="headerlink" href="#welcom
<dd class="field-odd"><p>0.17.6</p>
</dd>
<dt class="field-even">Date<span class="colon">:</span></dt>
<dd class="field-even"><p>Nov 29, 2023</p>
<dd class="field-even"><p>Dec 19, 2023</p>
</dd>
</dl>
<p>The <code class="docutils literal notranslate"><span class="pre">datascience</span></code> package was written for use in Berkeley’s DS 8 course and
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

65 changes: 40 additions & 25 deletions tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -448,17 +448,17 @@ <h2><a class="toc-backref" href="#id5" role="doc-backlink">Visualizing Data</a><

<span class="gp">In [47]: </span><span class="n">normal_data</span>
<span class="gh">Out[47]: </span>
<span class="go">data1 | data2</span>
<span class="go">0.500456 | 4.40152</span>
<span class="go">-3.82675 | 5.14587</span>
<span class="go">5.94581 | 8.75926</span>
<span class="go">2.62396 | 3.62318</span>
<span class="go">-0.808562 | 6.68086</span>
<span class="go">3.49924 | 5.07407</span>
<span class="go">2.03236 | 5.68779</span>
<span class="go">-1.18842 | 7.43892</span>
<span class="go">0.609402 | 3.94632</span>
<span class="go">5.20838 | 1.89229</span>
<span class="go">data1 | data2</span>
<span class="go">2.05981 | 8.1182</span>
<span class="go">-3.22487 | 1.0134</span>
<span class="go">2.16345 | 4.19344</span>
<span class="go">2.37821 | 5.85609</span>
<span class="go">1.21266 | 2.20146</span>
<span class="go">2.68269 | -3.23874</span>
<span class="go">0.879138 | 5.58776</span>
<span class="go">2.99951 | 5.77527</span>
<span class="go">3.7169 | -0.0626483</span>
<span class="go">0.788733 | 0.438713</span>
<span class="go">... (90 rows omitted)</span>
</pre></div>
</div>
Expand Down Expand Up @@ -510,17 +510,17 @@ <h2><a class="toc-backref" href="#id6" role="doc-backlink">Exporting</a><a class
converting to a pandas dataframe with <a class="reference internal" href="_autosummary/datascience.tables.Table.to_df.html#datascience.tables.Table.to_df" title="datascience.tables.Table.to_df"><code class="xref py py-meth docutils literal notranslate"><span class="pre">to_df()</span></code></a>:</p>
<div class="highlight-ipython notranslate"><div class="highlight"><pre><span></span><span class="gp">In [56]: </span><span class="n">normal_data</span>
<span class="gh">Out[56]: </span>
<span class="go">data1 | data2</span>
<span class="go">0.500456 | 4.40152</span>
<span class="go">-3.82675 | 5.14587</span>
<span class="go">5.94581 | 8.75926</span>
<span class="go">2.62396 | 3.62318</span>
<span class="go">-0.808562 | 6.68086</span>
<span class="go">3.49924 | 5.07407</span>
<span class="go">2.03236 | 5.68779</span>
<span class="go">-1.18842 | 7.43892</span>
<span class="go">0.609402 | 3.94632</span>
<span class="go">5.20838 | 1.89229</span>
<span class="go">data1 | data2</span>
<span class="go">2.05981 | 8.1182</span>
<span class="go">-3.22487 | 1.0134</span>
<span class="go">2.16345 | 4.19344</span>
<span class="go">2.37821 | 5.85609</span>
<span class="go">1.21266 | 2.20146</span>
<span class="go">2.68269 | -3.23874</span>
<span class="go">0.879138 | 5.58776</span>
<span class="go">2.99951 | 5.77527</span>
<span class="go">3.7169 | -0.0626483</span>
<span class="go">0.788733 | 0.438713</span>
<span class="go">... (90 rows omitted)</span>

<span class="go"># index = False prevents row numbers from appearing in the resulting CSV</span>
Expand Down Expand Up @@ -634,8 +634,8 @@ <h2><a class="toc-backref" href="#id7" role="doc-backlink">An Example</a><a clas

<span class="gp">In [73]: </span><span class="n">bootstrapped_diff_means</span><span class="p">[:</span><span class="mi">10</span><span class="p">]</span>
<span class="gh">Out[73]: </span>
<span class="go">array([-0.38369517, 0.60001524, 0.33484468, 0.51976477, 0.99375657,</span>
<span class="go"> 0.38784222, 0.6071088 , 0.61544556, 1.82818837, 0.78754666])</span>
<span class="go">array([-1.26916221, 0.57409997, 0.52478328, -0.87250788, 1.24177827,</span>
<span class="go"> -0.38085836, 0.65664183, -0.17360026, 1.84637628, 2.38732118])</span>

<span class="gp">In [74]: </span><span class="n">num_diffs_greater</span> <span class="o">=</span> <span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">bootstrapped_diff_means</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">abs</span><span class="p">(</span><span class="n">observed_diff</span><span class="p">))</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>

Expand All @@ -648,7 +648,22 @@ <h2><a class="toc-backref" href="#id7" role="doc-backlink">An Example</a><a clas
</section>
<section id="drawing-maps">
<h2><a class="toc-backref" href="#id8" role="doc-backlink">Drawing Maps</a><a class="headerlink" href="#drawing-maps" title="Link to this heading"></a></h2>
<p>To come.</p>
<p>The main class in the maps module is the Map class. In this code we create a default Map. Maps can be displayed or converted to html.</p>
<div class="highlight-ipython notranslate"><div class="highlight"><pre><span></span><span class="gp">In [77]: </span><span class="kn">from</span> <span class="nn">datascience.maps</span> <span class="kn">import</span> <span class="n">Map</span> <span class="c1"># import the Map class</span>

<span class="gp">In [78]: </span><span class="n">default_map</span> <span class="o">=</span> <span class="n">Map</span><span class="p">()</span> <span class="c1"># generate a default Map</span>

<span class="gp">In [79]: </span><span class="n">default_map</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> <span class="c1"># display the Map</span>
<span class="go">&lt;IPython.core.display.HTML object&gt;</span>

<span class="gp">In [80]: </span><span class="n">html</span> <span class="o">=</span> <span class="n">default_map</span><span class="o">.</span><span class="n">as_html</span><span class="p">()</span> <span class="c1"># generate the html</span>

<span class="gp">In [81]: </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;map.html&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="c1"># make a file to store the html</span>
<span class="gp"> ....: </span> <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">html</span><span class="p">)</span> <span class="c1"># write the html to the file</span>
<span class="gp"> ....: </span>
</pre></div>
</div>
<p>The maps modules also allows you to make custom maps with markers, circles and regions.</p>
</section>
</section>

Expand Down

0 comments on commit 8595643

Please sign in to comment.