Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're not already wedded to your design, I'd recommend looking at <a href="http://pandas.pydata.org/" rel="nofollow">pandas</a>. It makes stuff like this a lot easier than it would otherwise be. Getting the data:</p> <pre><code>&gt;&gt;&gt; from pandas.io.data import DataReader &gt;&gt;&gt; apple = DataReader("AAPL", "yahoo") &gt;&gt;&gt; apple &lt;class 'pandas.core.frame.DataFrame'&gt; DatetimeIndex: 786 entries, 2010-01-04 00:00:00 to 2013-02-15 00:00:00 Data columns: Open 786 non-null values High 786 non-null values Low 786 non-null values Close 786 non-null values Volume 786 non-null values Adj Close 786 non-null values dtypes: float64(5), int64(1) &gt;&gt;&gt; apple[:5] Open High Low Close Volume Adj Close Date 2010-01-04 213.43 214.50 212.38 214.01 17633200 210.90 2010-01-05 214.60 215.59 213.25 214.38 21496600 211.26 2010-01-06 214.38 215.23 210.75 210.97 19720000 207.90 2010-01-07 211.75 212.00 209.05 210.58 17040400 207.52 2010-01-08 210.30 212.00 209.06 211.98 15986100 208.90 </code></pre> <p>Adding a new column:</p> <pre><code>&gt;&gt;&gt; apple["new_column"] = apple["Open"]/apple["Volume"]**0.3 + 5 &gt;&gt;&gt; apple[:5] Open High Low Close Volume Adj Close new_column Date 2010-01-04 213.43 214.50 212.38 214.01 17633200 210.90 6.430066 2010-01-05 214.60 215.59 213.25 214.38 21496600 211.26 6.354936 2010-01-06 214.38 215.23 210.75 210.97 19720000 207.90 6.389032 2010-01-07 211.75 212.00 209.05 210.58 17040400 207.52 6.433440 2010-01-08 210.30 212.00 209.06 211.98 15986100 208.90 6.451164 </code></pre> <p>Choosing only the columns we want:</p> <pre><code>&gt;&gt;&gt; new = apple[["Close", "new_column"]] &gt;&gt;&gt; new[:5] Close new_column Date 2010-01-04 214.01 6.430066 2010-01-05 214.38 6.354936 2010-01-06 210.97 6.389032 2010-01-07 210.58 6.433440 2010-01-08 211.98 6.451164 </code></pre> <p>Et cetera.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload