Skip to content

Commit a6d41de

Browse files
authored
DOC: add note to how pandas deduplicate header when read from file (#57874)
add note
1 parent 22f930a commit a6d41de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/io/parsers/readers.py

+6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
194194
parameter ignores commented lines and empty lines if
195195
``skip_blank_lines=True``, so ``header=0`` denotes the first line of
196196
data rather than the first line of the file.
197+
198+
When inferred from the file contents, headers are kept distinct from
199+
each other by renaming duplicate names with a numeric suffix of the form
200+
``".{{count}}"`` starting from 1, e.g. ``"foo"`` and ``"foo.1"``.
201+
Empty headers are named ``"Unnamed: {{i}}"`` or ``"Unnamed: {{i}}_level_{{level}}"``
202+
in the case of MultiIndex columns.
197203
names : Sequence of Hashable, optional
198204
Sequence of column labels to apply. If the file contains a header row,
199205
then you should explicitly pass ``header=0`` to override the column names.

0 commit comments

Comments
 (0)