1import pandas as pd
2df.to_pickle(file_name) # save
3df = pd.read_pickle(file_name) # load
1# use pickle format to save columns with complex data (like list)
2# and keep their structure
3
4>>> original_df = pd.DataFrame({"foo": range(5), "bar": range(5, 10)})
5>>> original_df
6 foo bar
70 0 5
81 1 6
92 2 7
103 3 8
114 4 9
12>>> original_df.to_pickle("./dummy.pkl") # use read_pickle to read the dataframe