pandas.DataFrame.append¶
Append rows of other to the end of caller, returning a new object.
Columns in other that are not in the caller are added as new columns.
- param other
- DataFrame or Series/dict-like object, or list of these
The data to append.
- param ignore_index
- boolean, default False
If True, do not use the index labels.
- param verify_integrity
- boolean, default False
If True, raise ValueError on creating index with duplicates.
- param sort
- boolean, default None
Sort columns if the columns of self and other are not aligned. The default sorting is deprecated and will change to not-sorting in a future version of pandas. Explicitly pass
sort=True
to silence the warning and sort. Explicitly passsort=False
to silence the warning and not sort.New in version 0.23.0.
- return
DataFrame
Limitations¶
Parameters
verify_integrity
andsort
are unsupported.Parameter
other
can be onlypandas.DataFrame
.- Indexes of dataframes are expected to have comparable (both Numeric or String) types if parameter ignore_index
is set to False.
- This function may reveal slower performance than Pandas* on user system. Users should exercise a tradeoff
between staying in JIT-region with that function or going back to interpreter mode.
Examples¶
import pandas as pd
from numba import njit
@njit
def dataframe_append():
df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
df2 = pd.DataFrame({'B': [5, 6], 'C': [7, 8]})
result = df.append(df2)
return result
print(dataframe_append())
$ python ./dataframe/dataframe_append.py
A B C
0 1.0 3 NaN
1 2.0 4 NaN
0 NaN 5 7.0
1 NaN 6 8.0
See also
- pandas.concat
General function to concatenate DataFrame or Series objects.