Understanding the pandas IO API
00:00
Understanding the pandas IO API. Pandas IO Tools is the API that allows you to save the contents of Series
and DataFrame
objects to the clipboard, objects, or files of various types.
00:15
It also enables loading of data from the clipboard, objects, or files. Series
and DataFrame
objects have methods that enable writing data and labels to the clipboard or files. They’re named with the pattern to_<file-type>()
, where <file-type>
is the type of the target file. You’ve already learned about .to_csv()
and .to_excel()
, but there are others, including .to_json()
, .to_html()
, .to_sql()
, and .to_pickle()
.
00:44 There are still more file types that you can write to, so this list is not exhaustive.
00:50 These methods have parameters specifying the target file path where you save the data and labels. This is mandatory in some cases and optional in others.
01:01
If this option is available and you choose to omit it, then the methods return the objects—like strings or iterables—with the contents of the DataFrame
instances. There are a few other parameters, but they’re mostly specific to one or several methods.
01:16 You won’t get into them in detail here.
01:19
pandas functions for reading the contents of files are named using the pattern read_<file-type>()
, where, again, <file-type>
indicates the type of the file to be read.
01:29
You’ve already seen the pandas read_csv()
and read_excel()
functions, and these others follow the same pattern for the file types you’ll be covering in this course.
01:39
These functions have a parameter that specify the target file path. It can be any valid string that represents the path, either on a local machine or a URL, and it also accepts pathlib
objects.
01:52 There are other parameters, but they’re specific to one or several functions, and again, we won’t go into them in detail here.
02:00 So now that you’ve seen how the pandas IO API works, let’s get started by looking more closely at working with CSV files.
Become a Member to join the conversation.