Skip to content

Commit 3c6aded

Browse files
authored
DOC: Clarify how to keep lines with too many fields (#44652)
1 parent 8ffa2a9 commit 3c6aded

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/source/user_guide/io.rst

+14
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,20 @@ data that appear in some lines but not others:
13061306
1 4 5 6
13071307
2 8 9 10
13081308
1309+
In case you want to keep all data including the lines with too many fields, you can
1310+
specify a sufficient number of ``names``. This ensures that lines with not enough
1311+
fields are filled with ``NaN``.
1312+
1313+
.. code-block:: ipython
1314+
1315+
In [31]: pd.read_csv(StringIO(data), names=['a', 'b', 'c', 'd'])
1316+
1317+
Out[31]:
1318+
a b c d
1319+
0 1 2 3 NaN
1320+
1 4 5 6 7
1321+
2 8 9 10 NaN
1322+
13091323
.. _io.dialect:
13101324

13111325
Dialect

0 commit comments

Comments
 (0)