[Tutor] suggestions for splitting file based on date

Walter Prins wprins at gmail.com
Fri Jul 19 22:32:22 CEST 2013


Hi,

On 19 July 2013 20:24, Sivaram Neelakantan <nsivaram.net at gmail.com> wrote:

>
> I've got some stock indices data that I plan to plot using matplotlib.
> The data is simply date, idx_close_value and my plan is to plot the
> last 30 day, 90, 180 day & all time graphs of the indices.
>
> a) I can do the date computations using the python date libs
> b) plotting with matplotlib, I can get that done
>
> what is the best way to split the file into the last 30 day recs, 90
> day recs when the data is in increasing time order?  My initial
> thinking is to first reverse the file, append to various 30/90/180 day
> lists for every rec > computed date for the corresponding date
> windows.
>
> Is that the way to go or is there a better way?


You can do things manually as Peter's suggested, there's some value to be
had from learning to do things "by hand". However, if you're going to
continue to work with matplotlib and stock data I highly recommend you
eventually pick up and learn Pandas:  http://pandas.pydata.org/

Another useful link: https://bitbucket.org/hrojas/learn-pandas

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130719/fad1aa19/attachment.html>


More information about the Tutor mailing list