作者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://www.ptt.cc/bbs/Python/M.1612859676.A.52B.html
推 yuasa: skip_blank_lines=True會忽略到空白的row,而找第一個有內 02/09 21:39
→ yuasa: 容的row (如果header=0)來當header 02/09 21:39