Summary

In this chapter we showed how you can work with time series in Pandas. We introduced two index types, the DatetimeIndex and the TimedeltaIndex and explored their building blocks in depth. Pandas comes with versatile helper functions that take much of the pain out of parsing dates of various formats or generating fixed frequency sequences. Resampling data can help get a more condensed picture of the data, or it can help align various datasets of different frequencies to one another. One of the explicit goals of Pandas is to make it easy to work with missing data, which is also relevant in the context of upsampling.

Finally, we showed how time series can be visualized. Since matplotlib and Pandas are natural companions, we discovered that we can reuse our previous knowledge about matplotlib for time series data as well.

In the next chapter, we will explore ways to load and store data in text files and databases.

Practice exercises

Exercise 1: Find one or two real-world examples for data sets, which could – in a sensible way – be assigned to the following groups:

  • Fixed frequency data
  • Variable frequency data
  • Data where frequency is usually measured in seconds
  • Data where frequency is measured in nanoseconds
  • Data, where a TimedeltaIndex would be preferable

Create various fixed frequency ranges:

  • Every minute between 1 AM and 2 AM on 2000-01-01
  • Every two hours for a whole week starting 2000-01-01
  • An entry for every Saturday and Sunday during the year 2000
  • An entry for every Monday of a month, if it was a business day, for the years 2000, 2001 and 2002
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset