Working With Pickle Files
00:00 Working with pickle files. Pickling is the act of converting Python objects into byte streams. Unpickling is the reverse process. Python pickle files are binary files that keep the data and hierarchy of Python objects.
They usually have the extension
.pkl. You can save your DataFrame in a pickle file with
This creates a file
data.pickle containing the data. You could also pass an integer value to the optional parameter
protocol, which specifies the protocol of the pickler.
You can get the data from a pickle file with
read_pickle() returns the DataFrame with the stored data. You can also check the data types. These are the same ones that were specified before using
01:06 As a word of caution, you should always beware of loading pickles from untrusted sources. This can be dangerous. When you unpickle an untrustworthy file, it could execute arbitrary code on your machine, gain remote access to your computer, or otherwise exploit your device in other ways, so please be careful when doing this.
01:28 Having seen techniques in this section for working with a variety of file types, in the next section, you’re going to see techniques for working with large data files, which are becoming increasingly common in today’s data-driven society.
Become a Member to join the conversation.