How to save a Pandas Dataframe to a pickle file

0 votes

Hi Guys,

I am new to the Pandas module. I want to save the Dataframe in a pickle file. How can I do that?

Oct 18, 2020 in Python by akhtar
• 38,260 points
5,634 views

1 answer to this question.

0 votes

Hi@akhtar,

Python pickle module is used for serializing and de-serializing a Python object structure. Any object in Python can be pickled so that it can be saved on disk. You can use the below commands to save the Dataframe in a pickle file.

import pandas as pd
df = pd.DataFrame({"foo": range(5), "bar": range(5, 10)})
pd.to_pickle(df, "./dummy.pkl")
answered Oct 18, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,560 points
34,471 views
0 votes
1 answer

How to find if a value exists in Pandas dataframe?

Try this:​ for name in df['Name']: ...READ MORE

answered Apr 8, 2019 in Python by Tina
12,652 views
0 votes
1 answer

How to append a row to a Pandas dataframe?

You can use the append method provided by pandas ...READ MORE

answered May 9, 2019 in Python by Raj
2,823 views
0 votes
1 answer

How to print the index of a Pandas Dataframe?

You can do this using the code ...READ MORE

answered May 13, 2019 in Python by Usha
22,510 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,465 views
0 votes
1 answer
0 votes
1 answer

How to save one list in a text file in Python?

Hi@akhtar, There is no inbuilt function available to ...READ MORE

answered Jun 25, 2020 in Python by MD
• 95,460 points
3,796 views
0 votes
1 answer

How to write a HDF file from a DataFrame?

Hi@akhtar, Hierarchical Data Format (HDF) is a set ...READ MORE

answered Oct 18, 2020 in Python by MD
• 95,460 points
1,312 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP