Reading and Writing Files With pandas (Summary)
You now know how to save the data and labels from pandas DataFrame
objects to different kinds of files. You also know how to load your data from files and create DataFrame
objects.
You’ve used the pandas read_csv()
and .to_csv()
methods to read and write CSV files. You also used similar methods to read and write Excel, JSON, HTML, SQL, and pickle files. These functions are very convenient and widely used. They allow you to save or load your data in a single function or method call.
You’ve also learned how to save time, memory, and disk space when working with large data files:
- Compress or decompress files
- Choose the rows and columns you want to load
- Use less precise data types
- Split data into chunks and process them one by one
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
Summary. Well done! You’ve made it to the end of the course. In it, you’ve learned how to save the data and label from pandas DataFrame
objects to different file types.
00:12
You’ve also learned how to load data from those files and create DataFrame objects. You’ve used the pandas read_csv()
and .to_csv()
methods to read and write CSV files, and you’ve used similar methods to read and write Excel, JSON, HTML, SQL, and pickle files.
00:32 These functions are convenient and widely used. They allow you to save or load your data in a single function or method call.
00:40 You’ve also learned how to save time, memory, and disk space when working with large data files by using compression and decompression, choosing the rows and columns you want to load, using less precise data types, and splitting the data into chunks.
00:56 Using the wide range of techniques that you’ve learned in this course, you can be confident that you can use files in conjunction with pandas to use a wide range of data sources and store your data in an efficient manner.
01:09 We hope you found this course useful, and we’ll see you again soon at realpython.com.
Carlo Barrientos on May 14, 2024
I liked learning about Chunks when going through big data. I liked learning that pandas can ‘infer’ compression from filename suffix.
Become a Member to join the conversation.
Steven Wolk on Aug. 19, 2021
I learned about Pandas and pickle files. You can really get into a pickle if you are not careful!