上一期中,我们重点介绍了pandas中read_excel()中的index_col参数,本期介绍一下usecols参数。官方文档说明:(支持int,str,以及他们的列表,还支持函数调用,默认None解读所有列)usecols : int, str, list-like, or callable default NoneReturn a subset of the columns.
* If None, then parse all columns.
* If int, then indicates last column to be parsed.
.. deprecated:: 0.24.0
Pass in a list of int instead from 0 to `usecols` inclusive.
* If str, then indicates comma separated list of Excel column letters
and column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
both sides.
* If list of int, then indicates list of column numbers to be parsed.
* If list of string, then indicates list of column names to be parsed.
.. versionadded:: 0.24.0
* If callable, then evaluate each column name against it and parse the
column if the callable returns ``True``.