[Tutor] suggestions for splitting file based on date

Sivaram Neelakantan nsivaram.net at gmail.com
Sun Jul 21 07:31:18 CEST 2013


On Sat, Jul 20 2013,Walter Prins wrote:
[snipped 21 lines]

> 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
>

Pandas seems quite good, I was able to get a basic graph out with just
the following lines

colnames =['a','b','c','d','e','f','g']
df = pd.read_csv("cnx_100.dat", names=colnames, index_col=0,parse_dates=True)
plt.plot(df.index,df['e'])
plt.show()

The above plotted the index_day_close against the date.

I had to do the colnames part as I was getting the following
errors. Some rows have 6 cols, some 7.

CParserError: Error tokenizing data. C error: Expected 6 fields in
line 1350, saw 7

[snipped 6 lines]

 sivaram
 -- 



More information about the Tutor mailing list