beliav...@aol.com.dmarc.invalid wrote:

> I am going to read a multivariate time series from a CSV file that looks
> like
> 
> Date,A,B
> 2014-01-01,10.0,20.0
> 2014-01-02,10.1,19.9
> ...
> 
> The numerical data I will store in a NumPy array, since they are more
> convenient to work with than lists of lists. What are the advantages and
> disadvantages of storing the symbols [A,B] and dates
> [2014-01-01,2014-01-02] as lists vs. NumPy arrays?

If you don't mind the numpy dependency I can't see any disadvantages.
You might also have a look at pandas:

>>> ts = pandas.read_csv(io.StringIO("""\
... Date,A,B
... 2014-01-01,10.0,20.0
... 2014-01-02,10.1,19.9
... """), parse_dates=[0])
>>> ts
                 Date     A     B
0 2014-01-01 00:00:00  10.0  20.0
1 2014-01-02 00:00:00  10.1  19.9
>>> ts["A"]
0    10.0
1    10.1
Name: A, dtype: float64
>>> ts["Date"]
0   2014-01-01 00:00:00
1   2014-01-02 00:00:00
Name: Date, dtype: datetime64[ns]
>>> ts["Date"][0]
Timestamp('2014-01-01 00:00:00', tz=None)
>>> pylab.show(ts.plot(x="Date", y=["A", "B"]))


-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to