Repository: pandas-dev/pandas

Issue:
DOC: add warning to append about inefficiency
In many cases, using `append` to add rows is not the best way to go, as this is very inefficient (certainly if you do this in a for loop, each time taking a copy)

If in a situation where you have this pattern of appending in a for loop, you typically want to append to a list and then concatenate all at once using `concat`.

Would by good to add a note about this in the `append` docstring.


Discussion:
I'm working on it.
I've picked this up since it seems available again.
Sorry I haven't completed as I am stuck with the testing.

Go ahead if you want to do it.  Can I see how you do it after you are done?

Mo

Sent from my iPhone

> On Jul 15, 2017, at 9:53 PM, Andrew <notifications@github.com> wrote:
> 
> I've picked this up since it seems available again.
> 
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or mute the thread.
> 


Resolving patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -4618,6 +4618,11 @@ def append(self, other, ignore_index=False, verify_integrity=False):
         the DataFrame's index, the order of the columns in the resulting
         DataFrame will be unchanged.
 
+        Iteratively appending rows to a DataFrame can be more computationally
+        intensive than a single concatenate. A better solution is to append
+        those rows to a list and then concatenate the list with the original
+        DataFrame all at once.
+
         See also
         --------
         pandas.concat : General function to concatenate DataFrame, Series
@@ -4648,6 +4653,33 @@ def append(self, other, ignore_index=False, verify_integrity=False):
         2  5  6
         3  7  8
 
+        The following, while not recommended methods for generating DataFrames,
+        show two ways to generate a DataFrame from multiple data sources.
+
+        Less efficient:
+
+        >>> df = pd.DataFrame(columns=['A'])
+        >>> for i in range(5):
+        ...     df = df.append({'A'}: i}, ignore_index=True)
+        >>> df
+           A
+        0  0
+        1  1
+        2  2
+        3  3
+        4  4
+
+        More efficient:
+
+        >>> pd.concat([pd.DataFrame([i], columns=['A']) for i in range(5)],
+        ...           ignore_index=True)
+           A
+        0  0
+        1  1
+        2  2
+        3  3
+        4  4
+
         """
         if isinstance(other, (Series, dict)):
             if isinstance(other, dict):
diff --git a/pandas/core/series.py b/pandas/core/series.py
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -1522,6 +1522,18 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
         verify_integrity : boolean, default False
             If True, raise Exception on creating index with duplicates
 
+        Notes
+        -----
+        Iteratively appending to a Series can be more computationally intensive
+        than a single concatenate. A better solution is to append values to a
+        list and then concatenate the list with the original Series all at
+        once.
+
+        See also
+        --------
+        pandas.concat : General function to concatenate DataFrame, Series
+            or Panel objects
+
         Returns
         -------
         appended : Series


Test patch: