Serializing time series data with pickle
When working with data in Python, you may want to persist Python data structures or objects, such as a pandas DataFrame, to disk instead of keeping it in memory. One technique is to serialize your data into a byte stream to store it in 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.
Getting ready
The pickle
module comes with Python, so no additional installation is needed.
In this recipe, we will explore 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. Note that John Hopkins University is no longer updating the dataset...