polars.Series.append#
- Series.append(other: Series, *, append_chunks: bool | None = None) Self [source]#
Append a Series to this one.
- Parameters:
- other
Series to append.
- append_chunks
Deprecated since version 0.18.8: This argument will be removed and
append
will change to always behave likeappend_chunks=True
(the previous default). For the behavior ofappend_chunks=False
, useSeries.extend
.If set to
True
the append operation will add the chunks fromother
to self. This is super cheap.If set to
False
the append operation will do the same asDataFrame.extend
which extends the memory backed by thisSeries
with the values fromother
.Different from
append chunks
,extend
appends the data fromother
to the underlying memory locations and thus may cause a reallocation (which are expensive).If this does not cause a reallocation, the resulting data structure will not have any extra chunks and thus will yield faster queries.
Prefer
extend
overappend_chunks
when you want to do a query after a single append. For instance during online operations where you addn
rows and rerun a query.Prefer
append_chunks
overextend
when you want to append many times before doing a query. For instance when you read in multiple files and when to store them in a singleSeries
. In the latter case, finish the sequence ofappend_chunks
operations with arechunk
.
Warning
This method modifies the series in-place. The series is returned for convenience only.
See also
Examples
>>> a = pl.Series("a", [1, 2, 3]) >>> b = pl.Series("b", [4, 5]) >>> a.append(b) shape: (5,) Series: 'a' [i64] [ 1 2 3 4 5 ]
The resulting series will consist of multiple chunks.
>>> a.n_chunks() 2