Pickle files are commonly used Python data related projects. This article shows how to create and load pickle files using Pandas. 

Create pickle file

import pandas as pd 
import numpy as np

file_name="data/test.pkl"
data = np.random.randn(1000, 2)
# pd.set_option('display.max_rows', None)
df = pd.DataFrame(data=data, columns=['foo', 'bar'])
print(df)
df.to_pickle(file_name)

Read pickle file

import pandas as pd 
import numpy as np

file_name="data/test.pkl"
df2 = pd.read_pickle(file_name)
print(df2)
* This page is subject to Site terms.

More from Kontext

local_offer teradata local_offer python

visibility 198
thumb_up 0
access_time 1 month ago

Pandas is commonly used by Python users to perform data operations. In many scenarios, the results need to be saved to a storage like Teradata. This article shows you how to do that easily using JayDeBeApi or  ...

open_in_new View open_in_new Spark + PySpark

local_offer python

visibility 60
thumb_up 0
access_time 2 months ago

CSV is a common data format used in many applications. It's also a common task for data workers to read and parse CSV and then save it into another storage such as RDBMS (Teradata, SQL Server, MySQL). In my previous article  ...

open_in_new View open_in_new Python Programming

local_offer teradata local_offer python local_offer Java

visibility 127
thumb_up 0
access_time 2 months ago

Python JayDeBeApi module allows you to connect from Python to Teradata databases using Java JDBC drivers. In article Connect to Teradata database through Python , I showed ho...

open_in_new View open_in_new Python Programming

local_offer pandas local_offer sqlite

visibility 35
thumb_up 0
access_time 2 months ago

In my previous posts, I showed how to use  jaydebeapi or sqlite3 pack...

open_in_new View open_in_new Python Programming

info About author

Dark theme mode

Dark theme mode is available on Kontext.

Learn more arrow_forward

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.


Learn more arrow_forward