mirror of
https://github.com/redoules/redoules.github.io.git
synced 2025-12-12 15:59:34 +00:00
ajout de 4 articles
This commit is contained in:
parent
57fe0d71f5
commit
80f2eb9e98
@ -185,7 +185,7 @@ Mean : 43117.75, Median : 44627.5, Mode : 4978
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -219,7 +219,7 @@ Q1 : 6.0, Q2 : 12, Q3 : 16.0
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -429,7 +429,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -182,11 +182,11 @@
|
||||
<h3>Mathematical explanation</h3>
|
||||
<p>On the first draw, the probabilities are the following :
|
||||
we call B the event "a blue ball is drawn" and R the event "a red ball is drawn"
|
||||
<em> <span class="math">\(P(B)=\frac{4}{7}\)</span>
|
||||
</em> <span class="math">\(P(R)=\frac{3}{7}\)</span></p>
|
||||
* <span class="math">\(P(B)=\frac{4}{7}\)</span>
|
||||
* <span class="math">\(P(R)=\frac{3}{7}\)</span></p>
|
||||
<p>On the second draw, if a red ball has been drawn at first, the probabilities are :
|
||||
<em> <span class="math">\(P(B|R)=\frac{4}{6}\)</span>
|
||||
</em> <span class="math">\(P(R|R)=\frac{2}{6}\)</span></p>
|
||||
* <span class="math">\(P(B|R)=\frac{4}{6}\)</span>
|
||||
* <span class="math">\(P(R|R)=\frac{2}{6}\)</span></p>
|
||||
<p>Hence, the probability of drawing a blue ball if the first ball drawn was red is <span class="math">\(\frac{1}{3}\)</span></p>
|
||||
<script type="text/javascript">if (!document.getElementById('mathjaxscript_pelican_#%@#$@#')) {
|
||||
var align = "center",
|
||||
@ -256,7 +256,7 @@ we call B the event "a blue ball is drawn" and R the event "a red ball is drawn"
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -132,8 +132,8 @@
|
||||
<p>Let's first compute the probability of having a boy :</p>
|
||||
<div class="math">$$p_b=\frac{N_b}{N_b+N_g}$$</div>
|
||||
<p>where:
|
||||
<em> <span class="math">\(N_b\)</span> is the number of boys
|
||||
</em> <span class="math">\(N_g\)</span> is the number of girls
|
||||
* <span class="math">\(N_b\)</span> is the number of boys
|
||||
* <span class="math">\(N_g\)</span> is the number of girls
|
||||
* <span class="math">\(r=\frac{N_b}{N_g}\)</span></p>
|
||||
<div class="math">$$p_b=\frac{1}{1+\frac{1}{r}}$$</div>
|
||||
<div class="math">$$p_b=\frac{r}{r+1}$$</div>
|
||||
@ -173,8 +173,8 @@
|
||||
|
||||
<h3>Problem 2</h3>
|
||||
<p>A manufacturer of metal pistons finds that, 12% on average, of the pistons they manufacture are rejected because they are incorrectly sized. What is the probability that a batch of 10 pistons will contain:
|
||||
<em> No more than 2 rejects?
|
||||
</em> At least 2 rejects?</p>
|
||||
* No more than 2 rejects?
|
||||
* At least 2 rejects?</p>
|
||||
<h3>Mathematical explanation</h3>
|
||||
<p>On average 12% of the pistons are rejected, this means that a piston has a probability of <span class="math">\(p_{rejected}=0.12\)</span> to be rejected.</p>
|
||||
<p>The probability of getting less than 2 faulty pistons in a batch is :
|
||||
@ -212,8 +212,8 @@
|
||||
<p>The probability that a machine produces a defective product is <span class="math">\(\frac{1}{3}\)</span>. What is the probability that the first defect is found during the fith inspection?</p>
|
||||
<h3>Mathematical explanation</h3>
|
||||
<p>In this case, we will use a geometric distribution to evaluate the probability :
|
||||
<em> <span class="math">\(n=5\)</span>
|
||||
</em> <span class="math">\(p=\frac{1}{3}\)</span></p>
|
||||
* <span class="math">\(n=5\)</span>
|
||||
* <span class="math">\(p=\frac{1}{3}\)</span></p>
|
||||
<p>Hence, the probability that the first defect is found during the fith inspection is <span class="math">\(g(n=5,p=1/3)\)</span></p>
|
||||
<div class="highlight"><pre><span></span><span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s2">"The probability that the first defect is found during the fith inspection is {round(((1-p)**(n-1)) * p, 3)}"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
@ -311,7 +311,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -222,8 +222,8 @@ Between 20 and 22 hours?</p>
|
||||
|
||||
<h3>Problem 2</h3>
|
||||
<p>The final grades for a Physics exam taken by a large group of students have a mean of <span class="math">\(\mu=70\)</span> and a standard deviation of <span class="math">\(\sigma=10\)</span>. If we can approximate the distribution of these grades by a normal distribution, what percentage of the students:
|
||||
<em> Scored higher than 80 (i.e., have a <span class="math">\(grade \gt 80\)</span>))?
|
||||
</em> Passed the test (i.e., have a <span class="math">\(grade \gt 60\)</span>)?
|
||||
* Scored higher than 80 (i.e., have a <span class="math">\(grade \gt 80\)</span>))?
|
||||
* Passed the test (i.e., have a <span class="math">\(grade \gt 60\)</span>)?
|
||||
* Failed the test (i.e., have a <span class="math">\(grade \lt 60\)</span>)?</p>
|
||||
<h3>Mathematical explanation</h3>
|
||||
<p>Here again, we need to appy the cumulative density function to get the probabilities :</p>
|
||||
@ -331,7 +331,7 @@ Between 20 and 22 hours?</p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -129,8 +129,8 @@
|
||||
<p>A large elevator can transport a maximum of <span class="math">\(9800\)</span> kg. Suppose a load of cargo containing <span class="math">\(49\)</span> boxes must be transported via the elevator. The box weight of this type of cargo follows a distribution with a mean of <span class="math">\(\mu=205\)</span> kg and a standard deviation of <span class="math">\(\sigma=15\)</span> kg. Based on this information, what is the probability that all boxes can be safely loaded into the freight elevator and transported?</p>
|
||||
<h3>Mathematical explanation</h3>
|
||||
<p>This problem can be tackled with the central limit theorem. Since the number of boxes is "large", the sum of the weight approaches normal distribution with :
|
||||
<em> <span class="math">\(\mu' = n\mu\)</span>
|
||||
</em> <span class="math">\(\sigma'=\sigma\sqrt{n}\)</span></p>
|
||||
* <span class="math">\(\mu' = n\mu\)</span>
|
||||
* <span class="math">\(\sigma'=\sigma\sqrt{n}\)</span></p>
|
||||
<p>If we want to know the probability of the sum of the mass of all boxes to be under a certain weight, we can compute the cumulative density function :
|
||||
</p>
|
||||
<div class="math">$$P(x<9800) = F_X(9800)$$</div>
|
||||
@ -270,7 +270,7 @@ B = 515.68
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -272,7 +272,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -277,7 +277,7 @@ $$</div>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -275,7 +275,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -171,8 +171,8 @@ You must use sudo because it will write data to a system directory</p>
|
||||
<p>Save the file and exit; the updated crontab file will be installed for you.</p>
|
||||
<h4>Full Node</h4>
|
||||
<p>If you can afford to download and store all the blockchain, you can run a full node. At the time of writing, the blockchain is 150Go (<a href="https://blockchain.info/fr/charts/blocks-size">https://blockchain.info/fr/charts/blocks-size</a>). Tree ways to store this are :
|
||||
<em> use a microSD with 256Go or more
|
||||
</em> add a thumbdrive or an external drive to your raspberry pi
|
||||
* use a microSD with 256Go or more
|
||||
* add a thumbdrive or an external drive to your raspberry pi
|
||||
* mount a network drive from a NAS</p>
|
||||
<p>If you have purchased a big SD card then you can leave the default location for the blockchain data (~/.bitcoin/).
|
||||
Otherwise, you will have to change the datadir location to where your drive is mounted (in my case I have mounted it to /mnt)</p>
|
||||
@ -286,7 +286,7 @@ maxuploadtarget=5000
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -365,7 +365,7 @@ Mayer multiple average 1.3789102045356179
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -192,7 +192,7 @@ Epoch 5/5
|
||||
|
||||
|
||||
|
||||
&lt;keras.callbacks.History at 0x1582adc6780&gt;
|
||||
<keras.callbacks.History at 0x1582adc6780>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ Epoch 5/5
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -161,7 +161,7 @@ _________________________________________________________________
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -152,7 +152,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -154,7 +154,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -207,7 +207,7 @@ Epoch 5/5
|
||||
|
||||
|
||||
|
||||
&lt;keras.callbacks.History at 0x1d70aa62f28&gt;
|
||||
<keras.callbacks.History at 0x1d70aa62f28>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -235,7 +235,7 @@ Epoch 5/5
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -179,7 +179,7 @@ Epoch 5/5
|
||||
|
||||
|
||||
|
||||
&lt;keras.callbacks.History at 0x235c1bc1be0&gt;
|
||||
<keras.callbacks.History at 0x235c1bc1be0>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -259,7 +259,7 @@ Epoch 5/5
|
||||
|
||||
|
||||
|
||||
&lt;keras.callbacks.History at 0x235be1c76d8&gt;
|
||||
<keras.callbacks.History at 0x235be1c76d8>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -280,7 +280,7 @@ Epoch 5/5
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
BIN
images/Parula/output_2_0.png
Normal file
BIN
images/Parula/output_2_0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 430 KiB |
155
index.html
155
index.html
@ -405,6 +405,9 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./python/reverse_column_order.html">Reverse column order in pandas</a></li>
|
||||
<li><a href="./python/reverse_row_order.html">Reverse row order in pandas</a></li>
|
||||
<li><a href="./python/rename_columns_pandas.html">Rename columns in pandas</a></li>
|
||||
<li><a href="./python/pandas_extended_types.html">Using pandas extended types</a></li>
|
||||
<li><a href="./python/Moving_average_pandas.html">Moving average with pandas</a></li>
|
||||
<li><a href="./python/Reading_data_from_a_sql_database_with_pandas.html">Reading data from a sql database with pandas</a></li>
|
||||
@ -422,6 +425,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./python/Parula.html">Parula colormap for matplotlib</a></li>
|
||||
<li><a href="./python/logplot.html">Plotting data using log axis</a></li>
|
||||
<li><a href="./python/Setting_up_the_notebook_for_plotting_with_matplotlib.html">Setting up the notebook for plotting with matplotlib</a></li>
|
||||
<li><a href="./python/Saving_a_matplotlib_figure_with_a_high_resolution.html">Saving a matplotlib figure with a high resolution</a></li>
|
||||
@ -513,42 +517,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" id="UQ">
|
||||
<div class="col-sm-12">
|
||||
<h2 class="homepage_category_title">Uncertainty quantification</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Basics</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li>Coming soon.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">OpenTurns</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li>Coming soon.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -628,56 +598,17 @@
|
||||
|
||||
|
||||
<div class="row" id="Mathematics">
|
||||
<div class="col-sm-12">
|
||||
<h2 class="homepage_category_title">Mathematics</h2>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Basics</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./mathematics/Number_edges_Complete_graph.html">Number of edges in a Complete graph</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Statistics</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./mathematics/KLD.html">Kullback Leibler Divergence</a></li>
|
||||
<li><a href="./mathematics/spearman.html">Spearman's Rank Correlation Coefficient</a></li>
|
||||
<li><a href="./mathematics/pearson.html">Pearson correlation coefficient</a></li>
|
||||
<li><a href="./mathematics/normal.html">Normal Distribution</a></li>
|
||||
<li><a href="./mathematics/poisson.html">Poisson Distribution</a></li>
|
||||
<li><a href="./mathematics/Geometric.html">Geometric distribution</a></li>
|
||||
<li><a href="./mathematics/Binomial.html">Binomial distribution</a></li>
|
||||
<li><a href="./mathematics/Premutations_and_combinations.html">Premutations and combinations</a></li>
|
||||
<li><a href="./mathematics/cond_prob.html">Conditional Probability</a></li>
|
||||
<li><a href="./mathematics/Bayes.html">Bayes' Theorem</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" id="cryptocurrencies">
|
||||
<div class="col-sm-12">
|
||||
<h2 class="homepage_category_title">Cryptocurrencies</h2>
|
||||
<h2 class="homepage_category_title">Mathematics</h2>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Bitcoin</h3>
|
||||
<h3 class="panel-title">Basics</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./cryptocurrencies/Installing_bitcoind_on_raspberry_pi.html">Installing bitcoind on raspberry pi</a></li>
|
||||
<li><a href="./mathematics/Number_edges_Complete_graph.html">Number of edges in a Complete graph</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -685,7 +616,28 @@
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Forks/airdrops</h3>
|
||||
<h3 class="panel-title">Statistics</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./mathematics/KLD.html">Kullback Leibler Divergence</a></li>
|
||||
<li><a href="./mathematics/spearman.html">Spearman's Rank Correlation Coefficient</a></li>
|
||||
<li><a href="./mathematics/pearson.html">Pearson correlation coefficient</a></li>
|
||||
<li><a href="./mathematics/normal.html">Normal Distribution</a></li>
|
||||
<li><a href="./mathematics/poisson.html">Poisson Distribution</a></li>
|
||||
<li><a href="./mathematics/Geometric.html">Geometric distribution</a></li>
|
||||
<li><a href="./mathematics/Binomial.html">Binomial distribution</a></li>
|
||||
<li><a href="./mathematics/Premutations_and_combinations.html">Premutations and combinations</a></li>
|
||||
<li><a href="./mathematics/cond_prob.html">Conditional Probability</a></li>
|
||||
<li><a href="./mathematics/Bayes.html">Bayes' Theorem</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Uncertainty quantification</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
@ -694,21 +646,42 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Visualization</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./cryptocurrencies/mayer_multiple.html">Computing the Mayer multiple</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<div class="row" id="cryptocurrencies">
|
||||
<div class="col-sm-12">
|
||||
<h2 class="homepage_category_title">Cryptocurrencies</h2>
|
||||
</div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Bitcoin</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./cryptocurrencies/Installing_bitcoind_on_raspberry_pi.html">Installing bitcoind on raspberry pi</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Visualization</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
<li><a href="./cryptocurrencies/mayer_multiple.html">Computing the Mayer multiple</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -731,7 +704,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -211,7 +211,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -144,7 +144,7 @@ However, you can use the following command to do it </p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -203,7 +203,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -167,7 +167,7 @@ none 0 0 0 - /config
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -256,7 +256,7 @@ wifi0 Link encap:UNSPEC HWaddr 5C-51-4F-41-7A-AD-00-00-00-00-00-00-00-00-00
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -172,7 +172,7 @@ USER;PID;%CPU;%MEM;VSZ;RSS;TTY;STAT;START;TIME;COMMAND</p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -132,8 +132,8 @@
|
||||
|
||||
|
||||
<p>in the following example, we want to mount a NFS v3 share from :
|
||||
<em> server : 192.168.1.2
|
||||
</em> mountpoint (on the server) : /volumeUSB2/usbshare
|
||||
* server : 192.168.1.2
|
||||
* mountpoint (on the server) : /volumeUSB2/usbshare
|
||||
* mountlocation (on the client) : /mnt</p>
|
||||
<p>we specify</p>
|
||||
<div class="highlight"><pre><span></span><span class="m">192</span>.168.1.2:/volumeUSB2/usbshare /mnt nfs <span class="nv">nfsvers</span><span class="o">=</span><span class="m">3</span>,users <span class="m">0</span> <span class="m">0</span>
|
||||
@ -158,7 +158,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -169,7 +169,7 @@ dd <span class="k">if</span><span class="o">=</span>/dev/zero <span class="nv">o
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -126,8 +126,8 @@
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>In this article we will learn about some of the main uses we can use <code>sed</code> for :
|
||||
<em> replacing
|
||||
</em> deleting
|
||||
* replacing
|
||||
* deleting
|
||||
* printing </p>
|
||||
<p>For this example we will learn how to remove the comments starting with the '#' sign and the blank lines for the following file :</p>
|
||||
<div class="highlight"><pre><span></span>## Header of input.csv
|
||||
@ -494,7 +494,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -208,7 +208,7 @@ The secret number is 126
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -132,10 +132,10 @@
|
||||
|
||||
|
||||
<p>This will return :
|
||||
<em> the hostname
|
||||
</em> os name
|
||||
<em> kernel release/version
|
||||
</em> architecture
|
||||
* the hostname
|
||||
* os name
|
||||
* kernel release/version
|
||||
* architecture
|
||||
* etc.</p>
|
||||
<h3>variations</h3>
|
||||
<p>If you only want the kernel version you can type</p>
|
||||
@ -160,7 +160,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -234,7 +234,7 @@ Where Y=a+b*X
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -248,7 +248,7 @@ b_2\\
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -493,7 +493,7 @@ Confusion matrix, without normalization
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>{'classifier__C': 5.0, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': &lt;function mask_integers at 0x00000237491B67B8&gt;, 'vectorizer__stop_words': 'english'}
|
||||
<div class="highlight"><pre><span></span>{'classifier__C': 5.0, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': <function mask_integers at 0x00000237491B67B8>, 'vectorizer__stop_words': 'english'}
|
||||
0.711180124224
|
||||
Accuracy = 71.2%
|
||||
Confusion matrix, without normalization
|
||||
@ -506,16 +506,16 @@ Confusion matrix, without normalization
|
||||
|
||||
ValueError Traceback (most recent call last)
|
||||
|
||||
&lt;ipython-input-9-3e0781e307fb&gt; in &lt;module&gt;()
|
||||
<ipython-input-9-3e0781e307fb> in <module>()
|
||||
25 pipeline_performance(testing.label, predicted_labels)
|
||||
26
|
||||
---&gt; 27 print_top_features(pipeline1, n_features=10)
|
||||
---> 27 print_top_features(pipeline1, n_features=10)
|
||||
|
||||
|
||||
C:\Users\Guillaume\Documents\Code\recommandation\utils\plotting.py in print_top_features(pipeline, vectorizer_name, classifier_name, n_features)
|
||||
81 def print_top_features(pipeline, vectorizer_name='vectorizer', classifier_name='classifier', n_features=7):
|
||||
82 vocabulary = np.array(pipeline.named_steps[vectorizer_name].get_feature_names())
|
||||
---&gt; 83 coefs = pipeline.named_steps[classifier_name].coef_[0]
|
||||
---> 83 coefs = pipeline.named_steps[classifier_name].coef_[0]
|
||||
84 top_feature_idx = np.argsort(coefs)
|
||||
85 top_features = vocabulary[top_feature_idx]
|
||||
|
||||
@ -523,7 +523,7 @@ C:\Users\Guillaume\Documents\Code\recommandation\utils\plotting.py in print_top_
|
||||
C:\Users\Guillaume\Anaconda3\lib\site-packages\sklearn\svm\base.py in coef_(self)
|
||||
483 def coef_(self):
|
||||
484 if self.kernel != 'linear':
|
||||
--&gt; 485 raise ValueError('coef_ is only available when using a '
|
||||
--> 485 raise ValueError('coef_ is only available when using a '
|
||||
486 'linear kernel')
|
||||
487
|
||||
|
||||
@ -807,7 +807,7 @@ C:\Users\Guillaume\Anaconda3\lib\site-packages\sklearn\naive_bayes.py:801: Runti
|
||||
self.feature_log_prob_ = (np.log(smoothed_fc) -
|
||||
|
||||
|
||||
{'classifier__alpha': 0.25, 'classifier__fit_prior': True, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': &lt;function mask_integers at 0x00000237491B67B8&gt;, 'vectorizer__stop_words': 'english'}
|
||||
{'classifier__alpha': 0.25, 'classifier__fit_prior': True, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': <function mask_integers at 0x00000237491B67B8>, 'vectorizer__stop_words': 'english'}
|
||||
0.805900621118
|
||||
Accuracy = 78.1%
|
||||
Confusion matrix, without normalization
|
||||
@ -1002,7 +1002,7 @@ C:\Users\Guillaume\Anaconda3\lib\site-packages\sklearn\naive_bayes.py:699: Runti
|
||||
self.feature_log_prob_ = (np.log(smoothed_fc) -
|
||||
|
||||
|
||||
{'classifier__alpha': 0.5, 'classifier__fit_prior': False, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': &lt;function mask_integers at 0x00000237491B67B8&gt;, 'vectorizer__stop_words': 'english'}
|
||||
{'classifier__alpha': 0.5, 'classifier__fit_prior': False, 'vectorizer__ngram_range': (1, 1), 'vectorizer__preprocessor': <function mask_integers at 0x00000237491B67B8>, 'vectorizer__stop_words': 'english'}
|
||||
0.80900621118
|
||||
Accuracy = 79.1%
|
||||
Confusion matrix, without normalization
|
||||
@ -1033,7 +1033,7 @@ Top dislike features:
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -196,7 +196,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -256,7 +256,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -233,7 +233,7 @@ So :
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -195,7 +195,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -203,7 +203,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -197,7 +197,7 @@ and B are considered to be independent if event A has no effect on the probabili
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -130,8 +130,8 @@
|
||||
</p>
|
||||
<div class="math">$$\mathcal{N}(\mu,\sigma^2)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$$</div>
|
||||
<p>where,
|
||||
<em> <span class="math">\(\mu\)</span> is the mean (or expectation) of the distribution. It is also equal to median and mode of the distribution.
|
||||
</em> <span class="math">\(\sigma^2\)</span> is the variance.
|
||||
* <span class="math">\(\mu\)</span> is the mean (or expectation) of the distribution. It is also equal to median and mode of the distribution.
|
||||
* <span class="math">\(\sigma^2\)</span> is the variance.
|
||||
* <span class="math">\(\sigma\)</span> is the standard deviation. </p>
|
||||
<h2>Standard Normal Distribution</h2>
|
||||
<p>If <span class="math">\(\mu=0\)</span> and <span class="math">\(\sigma=1\)</span>, then the normal distribution is known as standard normal distribution:
|
||||
@ -221,7 +221,7 @@ where <span class="math">\(erf\)</span> is the error function:
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -206,7 +206,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -127,16 +127,16 @@
|
||||
<div class='article_content'>
|
||||
<h2>Poisson Experiment</h2>
|
||||
<p>Poisson experiment is a statistical experiment that has the following properties:
|
||||
<em> The outcome of each trial is either success or failure.
|
||||
</em> The average number of successes (<span class="math">\(\lambda\)</span>) that occurs in a specified region is known.
|
||||
<em> The probability that a success will occur is proportional to the size of the region.
|
||||
</em> The probability that a success will occur in an extremely small region is virtually zero. </p>
|
||||
* The outcome of each trial is either success or failure.
|
||||
* The average number of successes (<span class="math">\(\lambda\)</span>) that occurs in a specified region is known.
|
||||
* The probability that a success will occur is proportional to the size of the region.
|
||||
* The probability that a success will occur in an extremely small region is virtually zero. </p>
|
||||
<h2>Poisson Distribution</h2>
|
||||
<p>A Poisson random variable is the number of successes that result from a Poisson experiment. The probability distribution of a Poisson random variable is called a Poisson distribution:</p>
|
||||
<div class="math">$$P(k,\lambda)=\frac{\lambda^ke^{-\lambda}}{k!}$$</div>
|
||||
<p>where :
|
||||
<em> <span class="math">\(\lambda\)</span> is the average number of successes that occur in a specified region.
|
||||
</em> <span class="math">\(k\)</span> is the actual number of successes that occur in a specified region.
|
||||
* <span class="math">\(\lambda\)</span> is the average number of successes that occur in a specified region.
|
||||
* <span class="math">\(k\)</span> is the actual number of successes that occur in a specified region.
|
||||
* <span class="math">\(P(k,\lambda)\)</span> is the Poisson probability, which is the probability of getting exactly <span class="math">\(k\)</span> successes when the average number of successes is <span class="math">\(\lambda\)</span>. </p>
|
||||
<h2>Example</h2>
|
||||
<p>The average number of goals in the soccer world cup is 2.5. The probability that 4 goals are scored is then:
|
||||
@ -145,8 +145,8 @@
|
||||
<h2>Expectation for the Poisson distribution</h2>
|
||||
<p>Consider some Poisson random variable, <span class="math">\(X\)</span>. Let <span class="math">\(E[X]\)</span> be the expectation of <span class="math">\(X\)</span>. Find the value of <span class="math">\(E[X^2]\)</span>. </p>
|
||||
<p>Let <span class="math">\(Var(X)\)</span> be the variance of <span class="math">\(X\)</span>. Recall that if a random variable has a Poisson distribution, then:
|
||||
<em> <span class="math">\(E[X]=\lambda\)</span>
|
||||
</em> <span class="math">\(Var[X]=\lambda\)</span></p>
|
||||
* <span class="math">\(E[X]=\lambda\)</span>
|
||||
* <span class="math">\(Var[X]=\lambda\)</span></p>
|
||||
<p>Now, we'll use the following property of expectation and variance for any random variable, <span class="math">\(X\)</span>:
|
||||
</p>
|
||||
<div class="math">$$Var(X)=E[X^2]-(E[X])^2$$</div>
|
||||
@ -222,7 +222,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -127,8 +127,8 @@
|
||||
<div class='article_content'>
|
||||
<p>A rank correlation is any of several statistics that measure an ordinal association—the relationship between rankings of different ordinal variables or different rankings of the same variable, where a "ranking" is the assignment of the ordering labels "first", "second", "third", etc. to different observations of a particular variable. A rank correlation coefficient measures the degree of similarity between two rankings, and can be used to assess the significance of the relation between them. </p>
|
||||
<p>We have two random variables <span class="math">\(X\)</span> and <span class="math">\(Y\)</span>:
|
||||
<em> <span class="math">\(X=\{x_i, x_2, x_3, ..., x_n\}\)</span>
|
||||
</em> <span class="math">\(Y=\{y_i, y_2, y_3, ..., y_n\}\)</span></p>
|
||||
* <span class="math">\(X=\{x_i, x_2, x_3, ..., x_n\}\)</span>
|
||||
* <span class="math">\(Y=\{y_i, y_2, y_3, ..., y_n\}\)</span></p>
|
||||
<p>if <span class="math">\(Rank_X\)</span> and <span class="math">\(Rank_Y\)</span> denote the respective ranks of each data point, then the Spearman's rank correlation coefficient, <span class="math">\(r_s\)</span>, is the Pearson correlation coefficient of <span class="math">\(Rank_X\)</span> and <span class="math">\(Rank_Y\)</span>.</p>
|
||||
<h2>What does it means?</h2>
|
||||
<p>The Spearman's rank correlation coefficientis is a nonparametric measure of rank correlation (statistical dependence between the rankings of two variables). It assesses how well the relationship between two variables can be described using a monotonic function.
|
||||
@ -223,7 +223,7 @@ $$</div>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -192,7 +192,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -126,8 +126,8 @@
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>When you manipulate FEM results you generally have either a:
|
||||
<em> scalar field,
|
||||
</em> vector field,
|
||||
* scalar field,
|
||||
* vector field,
|
||||
* tensor field.</p>
|
||||
<p>With tensorial results, it is often useful to extract the eigenvalues in order to find the principal values.</p>
|
||||
<p>I have found that it is easier to store the components of the tensors in a 6 column pandas dataframe (because of the symmetric property of stress and strain tensors)</p>
|
||||
@ -241,7 +241,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -235,7 +235,7 @@ At line 5 there is a plum which is purple and contains 28 kcal
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -378,7 +378,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -192,7 +192,7 @@ If you try to open a non existing file in read mode 'r', a FileNotFoundError wil
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -176,7 +176,7 @@ conda install numpy --channel intel --override-channels
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
257
python/Parula.html
Normal file
257
python/Parula.html
Normal file
@ -0,0 +1,257 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Parula colormap for matplotlib - Python</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Data Visualization" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Parula colormap for matplotlib
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2019-08-04T11:01:00+02:00">
|
||||
04 août 2019
|
||||
</time>
|
||||
</li>
|
||||
<li>Python</li>
|
||||
<li>Data Visualization</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">matplotlib.colors</span> <span class="kn">import</span> <span class="n">LinearSegmentedColormap</span>
|
||||
<span class="n">cm_data</span> <span class="o">=</span> <span class="p">[[</span><span class="mf">0.2081</span><span class="p">,</span> <span class="mf">0.1663</span><span class="p">,</span> <span class="mf">0.5292</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.2116238095</span><span class="p">,</span> <span class="mf">0.1897809524</span><span class="p">,</span> <span class="mf">0.5776761905</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.212252381</span><span class="p">,</span> <span class="mf">0.2137714286</span><span class="p">,</span> <span class="mf">0.6269714286</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.2081</span><span class="p">,</span> <span class="mf">0.2386</span><span class="p">,</span> <span class="mf">0.6770857143</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.1959047619</span><span class="p">,</span> <span class="mf">0.2644571429</span><span class="p">,</span> <span class="mf">0.7279</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.1707285714</span><span class="p">,</span> <span class="mf">0.2919380952</span><span class="p">,</span>
|
||||
<span class="mf">0.779247619</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.1252714286</span><span class="p">,</span> <span class="mf">0.3242428571</span><span class="p">,</span> <span class="mf">0.8302714286</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0591333333</span><span class="p">,</span> <span class="mf">0.3598333333</span><span class="p">,</span> <span class="mf">0.8683333333</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0116952381</span><span class="p">,</span> <span class="mf">0.3875095238</span><span class="p">,</span>
|
||||
<span class="mf">0.8819571429</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0059571429</span><span class="p">,</span> <span class="mf">0.4086142857</span><span class="p">,</span> <span class="mf">0.8828428571</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0165142857</span><span class="p">,</span> <span class="mf">0.4266</span><span class="p">,</span> <span class="mf">0.8786333333</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.032852381</span><span class="p">,</span> <span class="mf">0.4430428571</span><span class="p">,</span>
|
||||
<span class="mf">0.8719571429</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0498142857</span><span class="p">,</span> <span class="mf">0.4585714286</span><span class="p">,</span> <span class="mf">0.8640571429</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0629333333</span><span class="p">,</span> <span class="mf">0.4736904762</span><span class="p">,</span> <span class="mf">0.8554380952</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0722666667</span><span class="p">,</span> <span class="mf">0.4886666667</span><span class="p">,</span>
|
||||
<span class="mf">0.8467</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0779428571</span><span class="p">,</span> <span class="mf">0.5039857143</span><span class="p">,</span> <span class="mf">0.8383714286</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.079347619</span><span class="p">,</span> <span class="mf">0.5200238095</span><span class="p">,</span> <span class="mf">0.8311809524</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0749428571</span><span class="p">,</span> <span class="mf">0.5375428571</span><span class="p">,</span>
|
||||
<span class="mf">0.8262714286</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0640571429</span><span class="p">,</span> <span class="mf">0.5569857143</span><span class="p">,</span> <span class="mf">0.8239571429</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0487714286</span><span class="p">,</span> <span class="mf">0.5772238095</span><span class="p">,</span> <span class="mf">0.8228285714</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0343428571</span><span class="p">,</span> <span class="mf">0.5965809524</span><span class="p">,</span>
|
||||
<span class="mf">0.819852381</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0265</span><span class="p">,</span> <span class="mf">0.6137</span><span class="p">,</span> <span class="mf">0.8135</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0238904762</span><span class="p">,</span> <span class="mf">0.6286619048</span><span class="p">,</span>
|
||||
<span class="mf">0.8037619048</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0230904762</span><span class="p">,</span> <span class="mf">0.6417857143</span><span class="p">,</span> <span class="mf">0.7912666667</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0227714286</span><span class="p">,</span> <span class="mf">0.6534857143</span><span class="p">,</span> <span class="mf">0.7767571429</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0266619048</span><span class="p">,</span> <span class="mf">0.6641952381</span><span class="p">,</span>
|
||||
<span class="mf">0.7607190476</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.0383714286</span><span class="p">,</span> <span class="mf">0.6742714286</span><span class="p">,</span> <span class="mf">0.743552381</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0589714286</span><span class="p">,</span> <span class="mf">0.6837571429</span><span class="p">,</span> <span class="mf">0.7253857143</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.0843</span><span class="p">,</span> <span class="mf">0.6928333333</span><span class="p">,</span> <span class="mf">0.7061666667</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.1132952381</span><span class="p">,</span> <span class="mf">0.7015</span><span class="p">,</span> <span class="mf">0.6858571429</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.1452714286</span><span class="p">,</span> <span class="mf">0.7097571429</span><span class="p">,</span> <span class="mf">0.6646285714</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.1801333333</span><span class="p">,</span> <span class="mf">0.7176571429</span><span class="p">,</span>
|
||||
<span class="mf">0.6424333333</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.2178285714</span><span class="p">,</span> <span class="mf">0.7250428571</span><span class="p">,</span> <span class="mf">0.6192619048</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.2586428571</span><span class="p">,</span> <span class="mf">0.7317142857</span><span class="p">,</span> <span class="mf">0.5954285714</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.3021714286</span><span class="p">,</span> <span class="mf">0.7376047619</span><span class="p">,</span>
|
||||
<span class="mf">0.5711857143</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.3481666667</span><span class="p">,</span> <span class="mf">0.7424333333</span><span class="p">,</span> <span class="mf">0.5472666667</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.3952571429</span><span class="p">,</span> <span class="mf">0.7459</span><span class="p">,</span> <span class="mf">0.5244428571</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.4420095238</span><span class="p">,</span> <span class="mf">0.7480809524</span><span class="p">,</span>
|
||||
<span class="mf">0.5033142857</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.4871238095</span><span class="p">,</span> <span class="mf">0.7490619048</span><span class="p">,</span> <span class="mf">0.4839761905</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.5300285714</span><span class="p">,</span> <span class="mf">0.7491142857</span><span class="p">,</span> <span class="mf">0.4661142857</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.5708571429</span><span class="p">,</span> <span class="mf">0.7485190476</span><span class="p">,</span>
|
||||
<span class="mf">0.4493904762</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.609852381</span><span class="p">,</span> <span class="mf">0.7473142857</span><span class="p">,</span> <span class="mf">0.4336857143</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.6473</span><span class="p">,</span> <span class="mf">0.7456</span><span class="p">,</span> <span class="mf">0.4188</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.6834190476</span><span class="p">,</span> <span class="mf">0.7434761905</span><span class="p">,</span> <span class="mf">0.4044333333</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.7184095238</span><span class="p">,</span> <span class="mf">0.7411333333</span><span class="p">,</span> <span class="mf">0.3904761905</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.7524857143</span><span class="p">,</span> <span class="mf">0.7384</span><span class="p">,</span> <span class="mf">0.3768142857</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.7858428571</span><span class="p">,</span> <span class="mf">0.7355666667</span><span class="p">,</span>
|
||||
<span class="mf">0.3632714286</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.8185047619</span><span class="p">,</span> <span class="mf">0.7327333333</span><span class="p">,</span> <span class="mf">0.3497904762</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.8506571429</span><span class="p">,</span> <span class="mf">0.7299</span><span class="p">,</span> <span class="mf">0.3360285714</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.8824333333</span><span class="p">,</span> <span class="mf">0.7274333333</span><span class="p">,</span> <span class="mf">0.3217</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.9139333333</span><span class="p">,</span> <span class="mf">0.7257857143</span><span class="p">,</span> <span class="mf">0.3062761905</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9449571429</span><span class="p">,</span> <span class="mf">0.7261142857</span><span class="p">,</span>
|
||||
<span class="mf">0.2886428571</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9738952381</span><span class="p">,</span> <span class="mf">0.7313952381</span><span class="p">,</span> <span class="mf">0.266647619</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.9937714286</span><span class="p">,</span> <span class="mf">0.7454571429</span><span class="p">,</span> <span class="mf">0.240347619</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9990428571</span><span class="p">,</span> <span class="mf">0.7653142857</span><span class="p">,</span>
|
||||
<span class="mf">0.2164142857</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9955333333</span><span class="p">,</span> <span class="mf">0.7860571429</span><span class="p">,</span> <span class="mf">0.196652381</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.988</span><span class="p">,</span> <span class="mf">0.8066</span><span class="p">,</span> <span class="mf">0.1793666667</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9788571429</span><span class="p">,</span> <span class="mf">0.8271428571</span><span class="p">,</span> <span class="mf">0.1633142857</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.9697</span><span class="p">,</span> <span class="mf">0.8481380952</span><span class="p">,</span> <span class="mf">0.147452381</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9625857143</span><span class="p">,</span> <span class="mf">0.8705142857</span><span class="p">,</span> <span class="mf">0.1309</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.9588714286</span><span class="p">,</span> <span class="mf">0.8949</span><span class="p">,</span> <span class="mf">0.1132428571</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9598238095</span><span class="p">,</span> <span class="mf">0.9218333333</span><span class="p">,</span>
|
||||
<span class="mf">0.0948380952</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.9661</span><span class="p">,</span> <span class="mf">0.9514428571</span><span class="p">,</span> <span class="mf">0.0755333333</span><span class="p">],</span>
|
||||
<span class="p">[</span><span class="mf">0.9763</span><span class="p">,</span> <span class="mf">0.9831</span><span class="p">,</span> <span class="mf">0.0538</span><span class="p">]]</span>
|
||||
|
||||
<span class="n">parula_map</span> <span class="o">=</span> <span class="n">LinearSegmentedColormap</span><span class="o">.</span><span class="n">from_list</span><span class="p">(</span><span class="s1">'parula'</span><span class="p">,</span> <span class="n">cm_data</span><span class="p">)</span>
|
||||
<span class="c1"># For use of "viscm view"</span>
|
||||
<span class="n">test_cm</span> <span class="o">=</span> <span class="n">parula_map</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="o">%</span><span class="n">matplotlib</span> <span class="n">inline</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
|
||||
|
||||
<span class="n">plt</span><span class="o">.</span><span class="n">rcParams</span><span class="p">[</span><span class="s1">'figure.figsize'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">12</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">viscm</span> <span class="kn">import</span> <span class="n">viscm</span>
|
||||
<span class="n">viscm</span><span class="p">(</span><span class="n">parula_map</span><span class="p">)</span>
|
||||
|
||||
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
|
||||
|
||||
<span class="k">print</span><span class="p">(</span><span class="s2">"viscm not found, falling back on simple display"</span><span class="p">)</span>
|
||||
<span class="n">plt</span><span class="o">.</span><span class="n">imshow</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">256</span><span class="p">)[</span><span class="bp">None</span><span class="p">,</span> <span class="p">:],</span> <span class="n">aspect</span><span class="o">=</span><span class="s1">'auto'</span><span class="p">,</span><span class="n">cmap</span><span class="o">=</span><span class="n">parula_map</span><span class="p">)</span>
|
||||
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p><img alt="png" src="../images/Parula/output_2_0.png"></p>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -237,7 +237,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>&lt;matplotlib.figure.Figure at 0x2e45e92f400&gt;
|
||||
<div class="highlight"><pre><span></span><matplotlib.figure.Figure at 0x2e45e92f400>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span>&lt;matplotlib.figure.Figure at 0x2e462164898&gt;
|
||||
<div class="highlight"><pre><span></span><matplotlib.figure.Figure at 0x2e462164898>
|
||||
</pre></div>
|
||||
</div>
|
||||
<aside>
|
||||
@ -186,7 +186,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -339,7 +339,7 @@ However, exporting to a sql database can prove very useful. Indeed, having a wel
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -169,7 +169,7 @@ myvariable: 42
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -181,7 +181,7 @@ The number 4 appears 1 times in the list
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -338,7 +338,7 @@ http://127.0.0.1:8787/status</p>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -232,7 +232,7 @@ The list of dependencies required to test, build and generate the doc are listed
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -164,7 +164,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="nt">b</span><span class="s1">'&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;Example Domain&lt;/title&gt;\n\n &lt;meta charset="utf-8" /&gt;\n &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8" /&gt;\n &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;\n &lt;style type="text/css"&gt;\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n body {\n background-color: #fff;\n }\n div {\n width: auto;\n margin: 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n }\n &lt;/style&gt; \n&lt;/head&gt;\n\n&lt;body&gt;\n&lt;div&gt;\n &lt;h1&gt;Example Domain&lt;/h1&gt;\n &lt;p&gt;This domain is established to be used for illustrative examples in documents. You may use this\n domain in examples without prior coordination or asking for permission.&lt;/p&gt;\n &lt;p&gt;&lt;a href="http://www.iana.org/domains/example"&gt;More information...&lt;/a&gt;&lt;/p&gt;\n&lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n'</span>
|
||||
<div class="highlight"><pre><span></span>b'<span class="cp"><!doctype html></span>\n<span class="nt"><html></span>\n<span class="nt"><head></span>\n <span class="nt"><title></span>Example Domain<span class="nt"></title></span>\n\n <span class="nt"><meta</span> <span class="na">charset=</span><span class="s">"utf-8"</span> <span class="nt">/></span>\n <span class="nt"><meta</span> <span class="na">http-equiv=</span><span class="s">"Content-type"</span> <span class="na">content=</span><span class="s">"text/html; charset=utf-8"</span> <span class="nt">/></span>\n <span class="nt"><meta</span> <span class="na">name=</span><span class="s">"viewport"</span> <span class="na">content=</span><span class="s">"width=device-width, initial-scale=1"</span> <span class="nt">/></span>\n <span class="nt"><style</span> <span class="na">type=</span><span class="s">"text/css"</span><span class="nt">></span>\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 50px;\n background-color: #fff;\n border-radius: 1em;\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n body {\n background-color: #fff;\n }\n div {\n width: auto;\n margin: 0 auto;\n border-radius: 0;\n padding: 1em;\n }\n }\n <span class="nt"></style></span> \n<span class="nt"></head></span>\n\n<span class="nt"><body></span>\n<span class="nt"><div></span>\n <span class="nt"><h1></span>Example Domain<span class="nt"></h1></span>\n <span class="nt"><p></span>This domain is established to be used for illustrative examples in documents. You may use this\n domain in examples without prior coordination or asking for permission.<span class="nt"></p></span>\n <span class="nt"><p><a</span> <span class="na">href=</span><span class="s">"http://www.iana.org/domains/example"</span><span class="nt">></span>More information...<span class="nt"></a></p></span>\n<span class="nt"></div></span>\n<span class="nt"></body></span>\n<span class="nt"></html></span>\n'
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -155,14 +155,14 @@
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="o">&</span><span class="nt">lt</span><span class="o">;!</span><span class="nt">DOCTYPE</span> <span class="nt">html</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">html</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">head</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">title</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span><span class="nt">Example</span> <span class="nt">Domain</span><span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">title</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">meta</span> <span class="nt">charset</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="o">/&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">meta</span> <span class="nt">content</span><span class="o">=</span><span class="s2">"text/html; charset=utf-8"</span> <span class="nt">http-equiv</span><span class="o">=</span><span class="s2">"Content-type"</span><span class="o">/&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">meta</span> <span class="nt">content</span><span class="o">=</span><span class="s2">"width=device-width, initial-scale=1"</span> <span class="nt">name</span><span class="o">=</span><span class="s2">"viewport"</span><span class="o">/&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">style</span> <span class="nt">type</span><span class="o">=</span><span class="s2">"text/css"</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<div class="highlight"><pre><span></span><span class="cp"><!DOCTYPE html></span>
|
||||
<span class="p"><</span><span class="nt">html</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>Example Domain<span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">content</span><span class="o">=</span><span class="s">"text/html; charset=utf-8"</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"Content-type"</span><span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">meta</span> <span class="na">content</span><span class="o">=</span><span class="s">"width=device-width, initial-scale=1"</span> <span class="na">name</span><span class="o">=</span><span class="s">"viewport"</span><span class="p">/></span>
|
||||
<span class="p"><</span><span class="nt">style</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/css"</span><span class="p">></span>
|
||||
<span class="nt">body</span> <span class="p">{</span>
|
||||
<span class="k">background-color</span><span class="p">:</span> <span class="mh">#f0f0f2</span><span class="p">;</span>
|
||||
<span class="k">margin</span><span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
|
||||
@ -192,17 +192,17 @@
|
||||
<span class="k">padding</span><span class="p">:</span> <span class="mi">1</span><span class="kt">em</span><span class="p">;</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">style</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">head</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">body</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">div</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">h1</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span><span class="nt">Example</span> <span class="nt">Domain</span><span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">h1</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">p</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span><span class="nt">This</span> <span class="nt">domain</span> <span class="nt">is</span> <span class="nt">established</span> <span class="nt">to</span> <span class="nt">be</span> <span class="nt">used</span> <span class="nt">for</span> <span class="nt">illustrative</span> <span class="nt">examples</span> <span class="nt">in</span> <span class="nt">documents</span><span class="o">.</span> <span class="nt">You</span> <span class="nt">may</span> <span class="nt">use</span> <span class="nt">this</span>
|
||||
<span class="nt">domain</span> <span class="nt">in</span> <span class="nt">examples</span> <span class="nt">without</span> <span class="nt">prior</span> <span class="nt">coordination</span> <span class="nt">or</span> <span class="nt">asking</span> <span class="nt">for</span> <span class="nt">permission</span><span class="o">.&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">p</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">p</span><span class="o">&</span><span class="nt">gt</span><span class="o">;&</span><span class="nt">lt</span><span class="o">;</span><span class="nt">a</span> <span class="nt">href</span><span class="o">=</span><span class="s2">"http://www.iana.org/domains/example"</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span><span class="nt">More</span> <span class="nt">information</span><span class="o">...&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">a</span><span class="o">&</span><span class="nt">gt</span><span class="o">;&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">p</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">div</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">body</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="o">&</span><span class="nt">lt</span><span class="o">;/</span><span class="nt">html</span><span class="o">&</span><span class="nt">gt</span><span class="o">;</span>
|
||||
<span class="p"></</span><span class="nt">style</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">div</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Example Domain<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">p</span><span class="p">></span>This domain is established to be used for illustrative examples in documents. You may use this
|
||||
domain in examples without prior coordination or asking for permission.<span class="p"></</span><span class="nt">p</span><span class="p">></span>
|
||||
<span class="p"><</span><span class="nt">p</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"http://www.iana.org/domains/example"</span><span class="p">></span>More information...<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<aside>
|
||||
@ -218,7 +218,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -213,7 +213,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -248,7 +248,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -126,12 +126,12 @@
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>Historically, pandas is bound to numpy arrays and its limitations :
|
||||
<em> integer and bool types cannot store missing data, indeed, <code>np.nan</code> is of type <code>np.float</code>
|
||||
</em> non-numeric types such as categorical, datetime are not natively supported. </p>
|
||||
* integer and bool types cannot store missing data, indeed, <code>np.nan</code> is of type <code>np.float</code>
|
||||
* non-numeric types such as categorical, datetime are not natively supported. </p>
|
||||
<p>Indeed, internally, pandas relies on numpy arrays to efficiently store and perform operations on the data.</p>
|
||||
<p>With the recent versions of pandas, it is possible to define custom types. In order to avoid having to extensively update the internal pandas code with each new extensions, it is now possible to define :
|
||||
<em> an extension type which describes the data type and can be registered for creation via a string (i.e. <code>...astype("example")</code>)
|
||||
</em> an extension array which is a class that handles the datatype. There is no real restriction on its construction though it must be convertible to a numpy array in order to make it work with the functions implemented in pandas. It is limited to one dimension.</p>
|
||||
* an extension type which describes the data type and can be registered for creation via a string (i.e. <code>...astype("example")</code>)
|
||||
* an extension array which is a class that handles the datatype. There is no real restriction on its construction though it must be convertible to a numpy array in order to make it work with the functions implemented in pandas. It is limited to one dimension.</p>
|
||||
<p>Some implementations are already implemented in pandas. For example, IntegerNA is a pandas extension that can handle missing integer data without casting to float (and loosing the precision).</p>
|
||||
<p><img alt="IntergerNA" src="../images/pandas_types_extend/intergerna.png"></p>
|
||||
<p>In order to use IntergerNA, you need to specify the type as "Int64" with a capital "i"</p>
|
||||
@ -158,12 +158,12 @@ dtype: Int64
|
||||
|
||||
<p>It is possible to leverage this extension to avoid running out of memory. For instance, we can store data using the "UInt16" type, this will avoid having to cast to float64.</p>
|
||||
<p>Other uses might be handling special data types such as :
|
||||
<em> ip adresses (see cyberpandas)
|
||||
</em> gps locations
|
||||
* ip adresses (see cyberpandas)
|
||||
* gps locations
|
||||
* etc...</p>
|
||||
<p><strong>sources</strong> :
|
||||
<em> https://pandas.pydata.org/pandas-docs/stable/extending.html
|
||||
</em> PyData LA 2018 Extending Pandas with Custom Types - Will Ayd
|
||||
* https://pandas.pydata.org/pandas-docs/stable/extending.html
|
||||
* PyData LA 2018 Extending Pandas with Custom Types - Will Ayd
|
||||
<a href="https://youtu.be/xx7H5EkzQH0" title="Extending Pandas with Custom Types - Will Ayd"><img alt="Extending Pandas with Custom Types - Will Ayd" src="http://img.youtube.com/vi/xx7H5EkzQH0/0.jpg"></a></p>
|
||||
<div class="highlight"><pre><span></span>
|
||||
</pre></div>
|
||||
@ -181,7 +181,7 @@ dtype: Int64
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -237,7 +237,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -156,7 +156,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
696
python/rename_columns_pandas.html
Normal file
696
python/rename_columns_pandas.html
Normal file
@ -0,0 +1,696 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Rename columns in pandas - Python</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Data Wrangling" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Rename columns in pandas
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2019-08-03T08:11:00+02:00">
|
||||
03 août 2019
|
||||
</time>
|
||||
</li>
|
||||
<li>Python</li>
|
||||
<li>Data Wrangling</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>In this article, we will be renaming columns in a pandas dataframe.
|
||||
First, let's import pandas and create an example dataframe</p>
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Import modules</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Example dataframe</span>
|
||||
|
||||
<span class="n">raw_data</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'fruit'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'Banana'</span><span class="p">,</span> <span class="s1">'Orange'</span><span class="p">,</span> <span class="s1">'Apple'</span><span class="p">,</span> <span class="s1">'lemon'</span><span class="p">,</span> <span class="s2">"lime"</span><span class="p">,</span> <span class="s2">"plum"</span><span class="p">],</span>
|
||||
<span class="s1">'color'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'yellow'</span><span class="p">,</span> <span class="s1">'orange'</span><span class="p">,</span> <span class="s1">'red'</span><span class="p">,</span> <span class="s1">'yellow'</span><span class="p">,</span> <span class="s2">"green"</span><span class="p">,</span> <span class="s2">"purple"</span><span class="p">],</span>
|
||||
<span class="s1">'kcal'</span><span class="p">:</span> <span class="p">[</span><span class="mi">89</span><span class="p">,</span> <span class="mi">47</span><span class="p">,</span> <span class="mi">52</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">28</span><span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">raw_data</span><span class="p">,</span> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'fruit'</span><span class="p">,</span> <span class="s1">'color'</span><span class="p">,</span> <span class="s1">'kcal'</span><span class="p">])</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>fruit</th>
|
||||
<th>color</th>
|
||||
<th>kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>The most flexible method for renaming columns in pandas is the rename method. It takes a dictornnary as an argument where :
|
||||
* the keys are the old names
|
||||
* the values are the new names
|
||||
you also need to specify the axis.</p>
|
||||
<p>This method can be used to rename either one or multiple columns</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">rename</span><span class="p">({</span><span class="s2">"fruit"</span> <span class="p">:</span> <span class="s2">"produce"</span><span class="p">,</span> <span class="s2">"kcal"</span><span class="p">:</span> <span class="s2">"energy"</span><span class="p">},</span> <span class="n">axis</span><span class="o">=</span><span class="s2">"columns"</span><span class="p">)</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>produce</th>
|
||||
<th>color</th>
|
||||
<th>energy</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>If you want to rename all the columns at once, a common method is to rewrite the columns attribute of the dataframe</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"nice fruit"</span><span class="p">,</span> <span class="s2">"bright color"</span><span class="p">,</span> <span class="s2">"light kcal"</span><span class="p">]</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>nice fruit</th>
|
||||
<th>bright color</th>
|
||||
<th>light kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>If the only thing you are doing is replacing a space with an underscore, an even better method is to use the str.replace method since you don't have to type all the column names</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">" "</span><span class="p">,</span> <span class="s2">"_"</span><span class="p">)</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>nice_fruit</th>
|
||||
<th>bright_color</th>
|
||||
<th>light_kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>Similarly, you can use other str methods such as :
|
||||
* capitalize : in order to converts first character to capital letter
|
||||
* lower : in order to have lowercase column names
|
||||
* upper : in order to have uppercase column names
|
||||
* etc.</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">columns</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">str</span><span class="o">.</span><span class="n">capitalize</span><span class="p">()</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>Nice_fruit</th>
|
||||
<th>Bright_color</th>
|
||||
<th>Light_kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>Finaly, if you only need to add a prefix or a suffix to the columns, you can use the add_prefix method</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">add_prefix</span><span class="p">(</span><span class="s2">"pre_"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>pre_Nice_fruit</th>
|
||||
<th>pre_Bright_color</th>
|
||||
<th>pre_Light_kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>or the add_suffix method</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">add_suffix</span><span class="p">(</span><span class="s2">"_post"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>Nice_fruit_post</th>
|
||||
<th>Bright_color_post</th>
|
||||
<th>Light_kcal_post</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -173,7 +173,7 @@ Reversed array : [4 3 2 1 0]
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
337
python/reverse_column_order.html
Normal file
337
python/reverse_column_order.html
Normal file
@ -0,0 +1,337 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Reverse column order in pandas - Python</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Data Wrangling" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Reverse column order in pandas
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2019-08-03T08:45:00+02:00">
|
||||
03 août 2019
|
||||
</time>
|
||||
</li>
|
||||
<li>Python</li>
|
||||
<li>Data Wrangling</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Import modules</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Example dataframe</span>
|
||||
|
||||
<span class="n">raw_data</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'fruit'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'Banana'</span><span class="p">,</span> <span class="s1">'Orange'</span><span class="p">,</span> <span class="s1">'Apple'</span><span class="p">,</span> <span class="s1">'lemon'</span><span class="p">,</span> <span class="s2">"lime"</span><span class="p">,</span> <span class="s2">"plum"</span><span class="p">],</span>
|
||||
<span class="s1">'color'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'yellow'</span><span class="p">,</span> <span class="s1">'orange'</span><span class="p">,</span> <span class="s1">'red'</span><span class="p">,</span> <span class="s1">'yellow'</span><span class="p">,</span> <span class="s2">"green"</span><span class="p">,</span> <span class="s2">"purple"</span><span class="p">],</span>
|
||||
<span class="s1">'kcal'</span><span class="p">:</span> <span class="p">[</span><span class="mi">89</span><span class="p">,</span> <span class="mi">47</span><span class="p">,</span> <span class="mi">52</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">28</span><span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">raw_data</span><span class="p">,</span> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'fruit'</span><span class="p">,</span> <span class="s1">'color'</span><span class="p">,</span> <span class="s1">'kcal'</span><span class="p">])</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>fruit</th>
|
||||
<th>color</th>
|
||||
<th>kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>The columns of a dataframe can be reversed by using the loc accessor and passing <code>:,::-1</code>. The <code>:</code> before the <code>,</code> means select all rows and the <code>::-1</code> after the <code>,</code> means reverse the column order</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">loc</span><span class="p">[:,::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>kcal</th>
|
||||
<th>color</th>
|
||||
<th>fruit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>89</td>
|
||||
<td>yellow</td>
|
||||
<td>Banana</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>47</td>
|
||||
<td>orange</td>
|
||||
<td>Orange</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>52</td>
|
||||
<td>red</td>
|
||||
<td>Apple</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>15</td>
|
||||
<td>yellow</td>
|
||||
<td>lemon</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>30</td>
|
||||
<td>green</td>
|
||||
<td>lime</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>28</td>
|
||||
<td>purple</td>
|
||||
<td>plum</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
408
python/reverse_row_order.html
Normal file
408
python/reverse_row_order.html
Normal file
@ -0,0 +1,408 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
<meta name="description" content="Data Science for Political and Social Phenomena">
|
||||
<meta name="author" content="Guillaume Redoulès">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
|
||||
<title>Reverse row order in pandas - Python</title>
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script>
|
||||
window.jQuery || document.write('<script src="../theme/js/jquery.min.js"><\/script>')
|
||||
</script>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="../theme/css/bootstrap.css" />
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/ie10-viewport-bug-workaround.css" />
|
||||
<!-- Custom styles for this template -->
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../theme/css/notebooks.css" />
|
||||
<link href='https://fonts.googleapis.com/css?family=PT+Serif:400,700|Roboto:400,500,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<meta name="tags" content="Data Wrangling" />
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="..">Guillaume Redoulès</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" id="searchbar">
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">About<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="../pages/about.html">About Guillaume</a></li>
|
||||
<li><a href="https://github.com/redoules">GitHub</a></li>
|
||||
<li><a href="https://www.linkedin.com/in/guillaume-redoul%C3%A8s-33923860/">LinkedIn</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Data Science<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="..#Blog">Blog</a></li>
|
||||
<li><a href="..#Python">Python</a></li>
|
||||
<li><a href="..#Bash">Bash</a></li>
|
||||
<li><a href="..#SQL">SQL</a></li>
|
||||
<li><a href="..#Mathematics">Mathematics</a></li>
|
||||
<li><a href="..#Machine_Learning">Machine Learning</a></li>
|
||||
<li><a href="..#Projects">Projects</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Projects<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="https://github.com/redoules/redoules.github.io">Notes (Github)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<!--<li class="dropdown">
|
||||
<a href="../feeds/blog.rss.xml">Blog RSS</a>
|
||||
</li>-->
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form" action="../search.html" onsubmit="return validateForm(this.elements['q'].value);">
|
||||
<div class="form-group" style="display:inline;">
|
||||
<div class="input-group" style="display:table;">
|
||||
<span class="input-group-addon" style="width:1%;"><span class="glyphicon glyphicon-search"></span></span>
|
||||
<input class="form-control search-query" name="q" id="tipue_search_input" placeholder="e.g. scikit KNN, pandas merge" required autocomplete="off" type="text">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- end of header section -->
|
||||
<div class="container">
|
||||
<!-- <div class="alert alert-warning" role="alert">
|
||||
Did you find this page useful? Please do me a quick favor and <a href="#" class="alert-link">endorse me for data science on LinkedIn</a>.
|
||||
</div> -->
|
||||
<section id="content" class="body">
|
||||
<header>
|
||||
<h1>
|
||||
Reverse row order in pandas
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<time class="published" datetime="2019-08-03T08:38:00+02:00">
|
||||
03 août 2019
|
||||
</time>
|
||||
</li>
|
||||
<li>Python</li>
|
||||
<li>Data Wrangling</li>
|
||||
</ol>
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Import modules</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="c1"># Example dataframe</span>
|
||||
|
||||
<span class="n">raw_data</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'fruit'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'Banana'</span><span class="p">,</span> <span class="s1">'Orange'</span><span class="p">,</span> <span class="s1">'Apple'</span><span class="p">,</span> <span class="s1">'lemon'</span><span class="p">,</span> <span class="s2">"lime"</span><span class="p">,</span> <span class="s2">"plum"</span><span class="p">],</span>
|
||||
<span class="s1">'color'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'yellow'</span><span class="p">,</span> <span class="s1">'orange'</span><span class="p">,</span> <span class="s1">'red'</span><span class="p">,</span> <span class="s1">'yellow'</span><span class="p">,</span> <span class="s2">"green"</span><span class="p">,</span> <span class="s2">"purple"</span><span class="p">],</span>
|
||||
<span class="s1">'kcal'</span><span class="p">:</span> <span class="p">[</span><span class="mi">89</span><span class="p">,</span> <span class="mi">47</span><span class="p">,</span> <span class="mi">52</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">28</span><span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">raw_data</span><span class="p">,</span> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'fruit'</span><span class="p">,</span> <span class="s1">'color'</span><span class="p">,</span> <span class="s1">'kcal'</span><span class="p">])</span>
|
||||
<span class="n">df</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>fruit</th>
|
||||
<th>color</th>
|
||||
<th>kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>The rows of a dataframe can be reversed by using the loc accessor and passing <code>::-1</code>. This notation is the same as the one used to reverse a list in python</p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">loc</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>fruit</th>
|
||||
<th>color</th>
|
||||
<th>kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>If you want to reset the index as well so that the dataframe starts with a 0, you can combine what we just learned with the <code>reset_index</code> method </p>
|
||||
<div class="highlight"><pre><span></span><span class="n">df</span><span class="o">.</span><span class="n">loc</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">reset_index</span><span class="p">(</span><span class="n">drop</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div>
|
||||
<style scoped>
|
||||
.dataframe tbody tr th:only-of-type {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.dataframe tbody tr th {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.dataframe thead th {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<table border="1" class="dataframe">
|
||||
<thead>
|
||||
<tr style="text-align: right;">
|
||||
<th></th>
|
||||
<th>fruit</th>
|
||||
<th>color</th>
|
||||
<th>kcal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>0</th>
|
||||
<td>plum</td>
|
||||
<td>purple</td>
|
||||
<td>28</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>1</th>
|
||||
<td>lime</td>
|
||||
<td>green</td>
|
||||
<td>30</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>2</th>
|
||||
<td>lemon</td>
|
||||
<td>yellow</td>
|
||||
<td>15</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>3</th>
|
||||
<td>Apple</td>
|
||||
<td>red</td>
|
||||
<td>52</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>4</th>
|
||||
<td>Orange</td>
|
||||
<td>orange</td>
|
||||
<td>47</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>5</th>
|
||||
<td>Banana</td>
|
||||
<td>yellow</td>
|
||||
<td>89</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p>that way, the rows are in reverse order but the index column has been re-initialized so it starts with 0</p>
|
||||
</div>
|
||||
<aside>
|
||||
<div class="bug-reporting__panel">
|
||||
<h3>Find an error or bug? Have a suggestion?</h3>
|
||||
<p>Everything on this site is avaliable on GitHub. Head on over and <a href='https://github.com/redoules/redoules.github.io/issues/new'>submit an issue.</a> You can also message me directly by <a href='mailto:guillaume.redoules@gadz.org'>email</a>.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<!-- start of footer section -->
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
</center>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This jQuery line finds any span that contains code highlighting classes and then selects the parent <pre> tag and adds a border. This is done as a workaround to visually distinguish the code inputs and outputs -->
|
||||
<script>
|
||||
$( ".hll, .n, .c, .err, .k, .o, .cm, .cp, .c1, .cs, .gd, .ge, .gr, .gh, .gi, .go, .gp, .gs, .gu, .gt, .kc, .kd, .kn, .kp, .kr, .kt, .m, .s, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nt, .nv, .ow, .w, .mf, .mh, .mi, .mo, .sb, .sc, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss, .bp, .vc, .vg, .vi, .il" ).parent( "pre" ).css( "border", "1px solid #DEDEDE" );
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Load Google Analytics -->
|
||||
<script>
|
||||
/*
|
||||
(function(i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function() {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-66582-32', 'auto');
|
||||
ga('send', 'pageview');
|
||||
*/
|
||||
</script>
|
||||
<!-- End of Google Analytics -->
|
||||
|
||||
<!-- Bootstrap core JavaScript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="../theme/js/bootstrap.min.js"></script>
|
||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||
<script src="../theme/js/ie10-viewport-bug-workaround.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -192,7 +192,7 @@ Sorted array : [0.13876208 0.19939047 0.40021786 0.43734158 0.46015169]
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -381,7 +381,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -171,7 +171,7 @@ Numpy array with unique values : [10 20 30 40 50 60]
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -151,7 +151,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
30
sitemap.xml
30
sitemap.xml
@ -5,7 +5,7 @@ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/</loc>
|
||||
<lastmod>2019-01-06T12:20:24-00:00</lastmod>
|
||||
<lastmod>2019-08-06T22:04:24-00:00</lastmod>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
@ -17,6 +17,34 @@ xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/Parula.html</loc>
|
||||
<lastmod>2019-08-04T11:01:00+02:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/reverse_column_order.html</loc>
|
||||
<lastmod>2019-08-03T08:45:00+02:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/reverse_row_order.html</loc>
|
||||
<lastmod>2019-08-03T08:38:00+02:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/python/rename_columns_pandas.html</loc>
|
||||
<lastmod>2019-08-03T08:11:00+02:00</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>redoules.github.io/sql/update_table.html</loc>
|
||||
<lastmod>2019-01-06T12:03:00+01:00</lastmod>
|
||||
|
||||
@ -344,7 +344,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -631,7 +631,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -216,7 +216,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -346,7 +346,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -126,8 +126,8 @@
|
||||
</header>
|
||||
<div class='article_content'>
|
||||
<p>The MariaDB users are granted access based on where the connection is coming from. By default the access is restricted to:
|
||||
<em> 127.0.0.1
|
||||
</em> localhost</p>
|
||||
* 127.0.0.1
|
||||
* localhost</p>
|
||||
<p>The program you are using to connect is not indentifying itself as 127.0.0.1 or localhost. You will have to verify the IP access it's being identified as, then add that to your grant table.</p>
|
||||
<p>In order to add grant an IP address you can use the following commands :</p>
|
||||
<div class="highlight"><pre><span></span>GRANT ALL ON *.* TO 'user'@'computer.host.com';
|
||||
@ -156,7 +156,7 @@ REVOKE ALL PRIVILEGES ON *.* FROM 'user'@'%'
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
@ -135,14 +135,7 @@ The database mydatabase.db is a SQLite database already created before the examp
|
||||
</pre></div>
|
||||
|
||||
|
||||
<div class="highlight"><pre><span></span><span class="n">The</span> <span class="n">sql</span> <span class="n">extension</span> <span class="n">is</span> <span class="n">already</span> <span class="n">loaded</span><span class="p">.</span> <span class="n">To</span> <span class="n">reload</span> <span class="n">it</span><span class="p">,</span> <span class="nl">use</span><span class="p">:</span>
|
||||
<span class="nf">%reload_ext</span> <span class="n">sql</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span class="err">'</span><span class="nl">Connected</span><span class="p">:</span> <span class="err">@</span><span class="n">mydatabase</span><span class="p">.</span><span class="n">db</span><span class="err">'</span>
|
||||
<div class="highlight"><pre><span></span>'Connected: @mydatabase.db'
|
||||
</pre></div>
|
||||
|
||||
|
||||
@ -312,7 +305,7 @@ Done.
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">
|
||||
<center>This project contains 84 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<center>This project contains 88 pages and is available on <a href="https://github.com/redoules/redoules.github.io">GitHub</a>.
|
||||
<br/>
|
||||
Copyright © Guillaume Redoulès,
|
||||
<time datetime="2018">2018</time>.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user