Specifying the index column when reading a CSV file

In the previous example, the index is numerical, starting from 0, instead of by date. This is because pandas does not assume that any specific column in the file should be used as the index. To help this situation, you can specify which column(s) should be the index in the call to read_csv() using the index_col parameter by assigning it the zero-based position of the column to be used as the index.

The following reads the data and tells pandas to use the column at position 0 in the file as the index (the Date column):

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset