O'Reilly logo

Mastering pandas by Femi Anthony

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling time series

In this section, we show you how to handle time series data. We will start by showing how to create time series data using the data read in from a csv file.

Reading in time series data

Here, we demonstrate the various ways to read in time series data:

In [7]: ibmData=pd.read_csv('ibm-common-stock-closing-prices-1959_1960.csv')
  ibmData.head()
Out[7]:    TradeDate     closingPrice
        0   1959-06-29   445
        1   1959-06-30   448
        2   1959-07-01   450
        3   1959-07-02   447
        4   1959-07-06   451
        5 rows 2 columns

The source of this information can be found at http://datamarket.com.

We would like the TradeDate column to be a series of datetime values so that we can index it and create a time series. Let us first check the type of values in the TradeDate series: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required