1 00:00:01,600 --> 00:00:02,333 2 00:00:02,333 --> 00:00:08,733 Hello and welcome to a video on saving files in Python. First, let's create some variables in our classdataS20 3 00:00:08,733 --> 00:00:08,766 4 00:00:08,766 --> 00:00:14,799 file. We'll go ahead and run this block of code. And you can see now we've 5 00:00:14,800 --> 00:00:21,000 created some variables in our data frame. Now that I've created these variables, what if I want to save them as a different 6 00:00:21,000 --> 00:00:21,033 7 00:00:21,033 --> 00:00:27,333 file type? So let's go ahead and do that. First, we'll create a new save file path with 8 00:00:27,333 --> 00:00:27,666 9 00:00:27,666 --> 00:00:33,599 the name of the file that we'd like to save it as. And then you use a method called 10 00:00:33,600 --> 00:00:33,733 11 00:00:33,733 --> 00:00:39,733 to_excel to save the 12 00:00:39,733 --> 00:00:45,833 file path using the file path that we've set up here. We're saying index false because we don't 13 00:00:45,833 --> 00:00:45,866 14 00:00:45,866 --> 00:00:52,399 want the index starting at zero right here, this index zero one two three four. 15 00:00:52,400 --> 00:00:52,433 16 00:00:52,433 --> 00:00:57,133 That's our index. We don't want that in our data frame that we're printing out. 17 00:00:57,133 --> 00:00:58,466 18 00:00:58,466 --> 00:01:04,499 Once I've saved that file path and run this line, it will go 19 00:01:04,500 --> 00:01:10,633 ahead and create a file in Google Drive in the place of specified and it will be an Excel file 20 00:01:10,633 --> 00:01:10,666 21 00:01:10,666 --> 00:01:16,899 with our variables inside it. If you'd like to do the same thing but with the CSV, this 22 00:01:16,900 --> 00:01:23,000 process is exactly the same except you use to_csv and in your 23 00:01:23,000 --> 00:01:23,033 24 00:01:23,033 --> 00:01:29,699 file path, you want to specify that it's a .csv instead of a .xlsx file. 25 00:01:29,700 --> 00:01:31,600 26 00:01:31,600 --> 00:01:37,366 Here are some other common file path types you may run across while working with data. We use JSONs for 27 00:01:37,366 --> 00:01:37,832 28 00:01:37,833 --> 00:01:43,366 APIs and data exchange. You might use two SQL if you're working with a SQL database table. 29 00:01:43,366 --> 00:01:44,199 30 00:01:44,200 --> 00:01:50,266 You may find yourself using to_pickle if you're working with Python objects and you may 31 00:01:50,266 --> 00:01:50,299 32 00:01:50,300 --> 00:01:53,066 use to_html if you're working on a website.