From the course: Python Data Analysis

Unlock the full course today

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

Importing data with pandas

Importing data with pandas - Python Tutorial

From the course: Python Data Analysis

Importing data with pandas

- [Instructor] We have already used pandas read_csv to load simple text tables into pandas. In this video, we look in detail at the task of importing textual data. We'll continue with example of planets. Let's have a look at the file planets.csv included in the exercise files. We see that all values are indeed separated by commas and that each line is a case, a record. The names of the columns or variables is given in the first line. Some values include commas as thousands separators and they are enclosed in quotes. A simple pandas code does a good job with this. However, looking at the structure of the data frame, we see that some columns that should be numbers have become strings instead, probably because of the commons, and that the date FirstVisited is also a string rather than a date. Luckily, pandas has options for that. We can specify the thousands separator and we can tell pandas explicitly that the FirstVisited column holds dates. For consistency, we can also require that the…

Contents