Specifying a column as an index

By default, read_csv assigns a default numeric index starting with zero while reading the data. However, you can change this behavior by passing the column name to the index column option. pandas will then set the index to this column, as shown in the following code:

df = pd.read_csv('IMDB.csv', encoding = "ISO-8859-1", index_col='Title')
df.head()

Here, we passed a movie title as the index name. Now the index name is Title, instead of a default numeric index, as shown in the following screenshot:

 

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

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