read_pickle()
Python Pandas Pandas Input Output
path ( file )
Path with file name to store the byte string of pickled data
compression
(Optional )Type of compression, {'infer', 'gzip', 'bz2', 'zip', 'xz', None}
We can read the binary file and create a DataFrame data by using read_pickle().
What is pickle ?
read_pickle to read data from Python Pickle file and create a Pandas DataFrame
VIDEO
import pandas as pd
import pickle
my_data=pd.read_pickle('my_data.pkl')
print(my_data)
Output
NAME ID MATH ENGLISH
0 Ravi 1 30 20
1 Raju 2 40 30
2 Alex 3 50 40
Read the
to_pickle() file to know how the
my_data.pkl file is created
The file is located in the current directory. Check for the file my_data.pkl . You can use path to read the file in different location.
my_data=pd.read_pickle("D:\my_data\my_data.pkl")
Compression
We can add compression option. ( You must have used the same type of compression while creating the file )
my_data=pd.read_pickle('my_data.pkl',compression='zip')
While creating the pickle we have to note the compression used. When we de-serialize or un-pickle the same file, we must use the same type of compression.
to_pickle()»
Read how to pickle data stored in a MySQL table.
« Pandas
read_clipboard()
read_html()
read_csv()
read_excel()
to_excel()
« Data input and output from Pandas DataFrame
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com