Serializing time series data with pickle
Often when working with data in Python, you may want to persist Python data structures or objects, such as a pandas DataFrame, to disk as opposed to keeping it in memory. One technique is to serialize your data into a byte stream to store to a file. In Python, the pickle module is a popular approach to object serialization and de-serialization (the reverse of serialization), also known as pickling and unpickling, respectively.
Getting ready
The pickle
module comes with Python and no additional installation is needed.
In this recipe, we will use two different methods for serializing the data, commonly referred to as pickling.
You will be using the COVID-19 dataset provided by the COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University, which you can download from the official GitHub repository here: https://github.com/CSSEGISandData/COVID-19.
How to do it…
You will...