Skip to content

Commit 17c6e2b

Browse files
authored
DOC: Improve reshape\concat (#47061)
1 parent 40a88f8 commit 17c6e2b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/core/reshape/concat.py

+19
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ def concat(
226226
pandas objects can be found `here
227227
<https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html>`__.
228228
229+
It is not recommended to build DataFrames by adding single rows in a
230+
for loop. Build a list of rows and make a DataFrame in a single concat.
231+
229232
Examples
230233
--------
231234
Combine two ``Series``.
@@ -344,6 +347,22 @@ def concat(
344347
Traceback (most recent call last):
345348
...
346349
ValueError: Indexes have overlapping values: ['a']
350+
351+
Append a single row to the end of a ``DataFrame`` object.
352+
353+
>>> df7 = pd.DataFrame({'a': 1, 'b': 2}, index=[0])
354+
>>> df7
355+
a b
356+
0 1 2
357+
>>> new_row = pd.Series({'a': 3, 'b': 4})
358+
>>> new_row
359+
a 3
360+
b 4
361+
dtype: int64
362+
>>> pd.concat([df7, new_row.to_frame().T], ignore_index=True)
363+
a b
364+
0 1 2
365+
1 3 4
347366
"""
348367
op = _Concatenator(
349368
objs,

0 commit comments

Comments
 (0)