cudf.DataFrame.append#
- DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=False)#
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.
- Parameters
- otherDataFrame or Series/dict-like object, or list of these
The data to append.
- ignore_indexbool, default False
If True, do not use the index labels.
- sortbool, default False
Sort columns ordering if the columns of self and other are not aligned.
- verify_integritybool, default False
This Parameter is currently not supported.
- Returns
- DataFrame
See also
cudf.concat
General function to concatenate DataFrame or objects.
Notes
If a list of dict/series is passed and the keys are all contained in the DataFrame’s index, the order of the columns in the resulting DataFrame will be unchanged. Iteratively appending rows to a cudf 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. verify_integrity parameter is not supported yet.
Examples
>>> import cudf >>> df = cudf.DataFrame([[1, 2], [3, 4]], columns=list('AB')) >>> df A B 0 1 2 1 3 4 >>> df2 = cudf.DataFrame([[5, 6], [7, 8]], columns=list('AB')) >>> df2 A B 0 5 6 1 7 8 >>> df.append(df2) A B 0 1 2 1 3 4 0 5 6 1 7 8
With ignore_index set to True:
>>> df.append(df2, ignore_index=True) A B 0 1 2 1 3 4 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 = cudf.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 than above:
>>> cudf.concat([cudf.DataFrame([i], columns=['A']) for i in range(5)], ... ignore_index=True) A 0 0 1 1 2 2 3 3 4 4