to_pickle()

Pandas

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}
protocol(Optional) , Int, we can use HIGHEST_PROTOCOL to get the latest
DataFrame to file by to_pickle() We can create a file with DataFrame data by using to_pickle(). We will create one DataFrame by using a dictionary.
import pandas as pd
import pickle
my_dict={
	'NAME':['Ravi','Raju','Alex'],
	'ID':[1,2,3],'MATH':[30,40,50],
	'ENGLISH':[20,30,40]
	}
my_data = pd.DataFrame(data=my_dict)
my_data.to_pickle("my_data.pkl") # pickled
This is the data written to the current directory. Check for the file my_data.pkl . You can use path to store the file in different location.
my_data.to_pickle("D:\my_data\my_data.pkl")

Compression

We can add compression option. ( You must take care while reading the same file )
my_data.to_pickle("my_data.pkl",compression='zip') 

protocol

We can assign the integer or we can get the latest by using HIGHEST_PROTOCOL
my_data.to_pickle("my_data.pkl",protocol=pickle.HIGHEST_PROTOCOL)
read_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


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer