From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Column selection

Column selection

- [Instructor] It's possible to select a column as your index column while reading in your DataFrame. We can do so by using the index_col argument. If we wanted to, we could also pass a list of column names to create a multi-index DataFrame. Most of you probably know my preferences by now and know that I don't do this very often, but it is possible. In additionally, if we want to set a date column as our index column, we want to specify parse_dates equals true to convert that column into a datetime 64 data type. So here we're reading in monthly sales CSV and specifying date as our index column. And note that if we just leave it like this, our date will be stored as an object. In order to convert our index column, which is a datetime, into a datetime, we need to specify parse_dates equals true. And note that when we return the data type of our index, we get this M8 nanosecond piece here. This is a synonym for datetime 64. It's a little bit convoluted, but just know if you see this…

Contents