作者jaids (做工的人)
看板Python
标题[问题] pandas read_csv的header设0跟None跟1不同
时间Tue Feb 9 16:34:32 2021
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? 我这样理解对吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 77.16.48.92 (挪威)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1612859676.A.52B.html
1F:推 yuasa: skip_blank_lines=True会忽略到空白的row,而找第一个有内 02/09 21:39
2F:→ yuasa: 容的row (如果header=0)来当header 02/09 21:39