Choose columns. The pandas
read_excel() functions have the optional parameter
usecols that you can use to specify the columns you want to load from the file.
00:14 You can pass the list of column names as the corresponding argument. Now you have a DataFrame that contains less data than before. Here, there are only the names of the countries and their areas.
00:35 Instead of the column names, you can also pass their indices.
You can see the following columns: the column at index
0 contains the row labels, the column at index
1 contains the country names, and the column at index
3 contains the areas.
read_sql() has the optional parameter
columns that takes a list of column names to read.
Again, the DataFrame only contains the columns with the names of the countries and their areas. If
None or omitted, then all of the columns will be read, as you saw before. The default behavior is
Become a Member to join the conversation.