[问题] pandas read_csv的header设0跟None跟1不同

楼主: jaids (j-aids)   2021-02-09 16:34:32
pandas.read_csv的header
header int, list of int, default ‘infer’
Row number(s) to use as the column names, and the start of the data. Default
behavior is to infer the column names: if no names are passed the behavior is
identical to header=0 and column names are inferred from the first line of
the file, if column names are passed explicitly then the behavior is
identical to header=None. Explicitly pass header=0 to be able to replace
existing names. The header can be a list of integers that specify row
locations for a multi-index on the columns e.g. [0,1,3]. Intervening rows
that are not specified will be skipped (e.g. 2 in this example is skipped).
Note that this parameter ignores commented lines and empty lines if
skip_blank_lines=True, so header=0 denotes the first line of data rather than
the first line of the file.
请问
他最后一句是说skip_blank_lines=True的情形下header=0指称第一个row是header吗?
(所以会越过第一个row)
如果header=1是不是就会略过前两个row
而header=None不会略过任何row? 我这样理解对吗?
作者: yuasa (XD)   2021-02-09 21:39:00
skip_blank_lines=True会忽略到空白的row,而找第一个有内容的row (如果header=0)来当header

Links booklink

Contact Us: admin [ a t ] ucptt.com