From the course: Python for Data Science Tips, Tricks, & Techniques

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Export data with Pandas

Export data with Pandas - Python Tutorial

From the course: Python for Data Science Tips, Tricks, & Techniques

Start my 1-month free trial

Export data with Pandas

- [Instructor] After we've read data in using pandas, we've converted it into something that our users are going to want to see, we often need to share it with them by exporting the data to a different format for them. So in this video, I'm going to open up the exercise files and show you how essentially to build some aggregations and then put that out as a CSV, JSON file, and even an Excel file. First we start by importing pandas. Then we're going to go ahead and read in the CSV file. Then we're going to create a yearly product sales totals. Remember we're using the Group By function of our data frame and we're giving it the year and product name and we're doing a sum operation. After that, we just go ahead and rename the columns from month of order date to year of order, something that makes a bit more sense; and then I'd want to export it. So here what I have is the to_csv function. I give it the file path, and then I give it some parameters for the CSV part. So the header is true,…

Contents