From the course: Advanced Python: Top Tools for Data Science and Engineering

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Reading and writing data files with pandas

Reading and writing data files with pandas

- [Instructor] In the previous example, we programmatically created a data frame from a dictionary object. And of course, in the real world, data isn't usually stored like that. More commonly, you'll need to read the data from a data source like an Excel or CSV file, or maybe another format like JSON or even HTML or from a database. pandas can read and write data in a variety of common formats. I've listed a few of them in this table, along with the corresponding pandas functions that are used to read and write that particular format. Perhaps the most common are these spreadsheet-based formats like Excel and CSV. To read these files, you would use the read_excel and read_csv functions. And to write them, you would use to_excel and to_csv. In fact, you've probably noticed that each of the read functions starts with the read prefix and each of the writing function uses the to prefix. In addition to Excel and CSV, pandas can also work with XML and JSON files, which are very common data…

Contents