@@ -103,15 +103,20 @@ Column and Index Locations and Names
103
103
++++++++++++++++++++++++++++++++++++
104
104
105
105
header : int or list of ints, default ``'infer' ``
106
- Row number(s) to use as the column names, and the start of the data. Default
107
- behavior is as if ``header=0 `` if no ``names `` passed, otherwise as if
108
- ``header=None ``. Explicitly pass ``header=0 `` to be able to replace existing
109
- names. The header can be a list of ints that specify row locations for a
110
- multi-index on the columns e.g. ``[0,1,3] ``. Intervening rows that are not
111
- specified will be skipped (e.g. 2 in this example is skipped). Note that
112
- this parameter ignores commented lines and empty lines if
113
- ``skip_blank_lines=True ``, so header=0 denotes the first line of data
114
- rather than the first line of the file.
106
+ Row number(s) to use as the column names, and the start of the
107
+ data. Default behavior is to infer the column names: if no names are
108
+ passed the behavior is identical to ``header=0 `` and column names
109
+ are inferred from the first line of the file, if column names are
110
+ passed explicitly then the behavior is identical to
111
+ ``header=None ``. Explicitly pass ``header=0 `` to be able to replace
112
+ existing names.
113
+
114
+ The header can be a list of ints that specify row locations
115
+ for a multi-index on the columns e.g. ``[0,1,3] ``. Intervening rows
116
+ that are not specified will be skipped (e.g. 2 in this example is
117
+ skipped). Note that this parameter ignores commented lines and empty
118
+ lines if ``skip_blank_lines=True ``, so header=0 denotes the first
119
+ line of data rather than the first line of the file.
115
120
names : array-like, default ``None ``
116
121
List of column names to use. If file contains no header row, then you should
117
122
explicitly pass ``header=None ``. Duplicates in this list will cause
@@ -553,6 +558,14 @@ If the header is in a row other than the first, pass the row number to
553
558
data = ' skip this skip it\n a,b,c\n 1,2,3\n 4,5,6\n 7,8,9'
554
559
pd.read_csv(StringIO(data), header = 1 )
555
560
561
+ .. note ::
562
+
563
+ Default behavior is to infer the column names: if no names are
564
+ passed the behavior is identical to ``header=0 `` and column names
565
+ are inferred from the first nonblank line of the file, if column
566
+ names are passed explicitly then the behavior is identical to
567
+ ``header=None ``.
568
+
556
569
.. _io.dupe_names :
557
570
558
571
Duplicate names parsing
0 commit comments