bigframes.pandas.concat#
- bigframes.pandas.concat(objs:Iterable[bigframes.series.Series],*,axis:Literal['index',0]=0,join='outer',ignore_index=False)→bigframes.series.Series[source]#
- bigframes.pandas.concat(objs:Iterable[bigframes.dataframe.DataFrame],*,axis:Literal['index',0]=0,join='outer',ignore_index=False)→bigframes.dataframe.DataFrame
- bigframes.pandas.concat(objs:Iterable[bigframes.dataframe.DataFrame|bigframes.series.Series],*,axis:Literal['columns',1],join='outer',ignore_index=False)→bigframes.dataframe.DataFrame
- bigframes.pandas.concat(objs:Iterable[bigframes.dataframe.DataFrame|bigframes.series.Series],*,axis=0,join='outer',ignore_index=False)→bigframes.dataframe.DataFrame|bigframes.series.Series
Concatenate BigQuery DataFrames objects along a particular axis.
Allows optional set logic along the other axes.
Can also add a layer of hierarchical indexing on the concatenation axis,which may be useful if the labels are the same (or overlapping) onthe passed axis number.
Note
It is not recommended to build DataFrames by adding single rows in afor loop. Build a list of rows and make a DataFrame in a single concat.
Examples:
>>>importbigframes.pandasaspd>>>pd.options.display.progress_bar=None
Combine two
Series.>>>s1=pd.Series(['a','b'])>>>s2=pd.Series(['c','d'])>>>pd.concat([s1,s2])0 a1 b0 c1 ddtype: string
Clear the existing index and reset it in the resultby setting the
ignore_indexoption toTrue.>>>pd.concat([s1,s2],ignore_index=True)0 a1 b2 c3 ddtype: string
Combine two
DataFrameobjects with identical columns.>>>df1=pd.DataFrame([['a',1],['b',2]],...columns=['letter','number'])>>>df1 letter number0 a 11 b 2[2 rows x 2 columns]>>>df2=pd.DataFrame([['c',3],['d',4]],...columns=['letter','number'])>>>df2 letter number0 c 31 d 4[2 rows x 2 columns]>>>pd.concat([df1,df2]) letter number0 a 11 b 20 c 31 d 4[4 rows x 2 columns]
Combine
DataFrameobjects with overlapping columnsand return everything. Columns outside the intersection willbe filled withNaNvalues.>>>df3=pd.DataFrame([['c',3,'cat'],['d',4,'dog']],...columns=['letter','number','animal'])>>>df3 letter number animal0 c 3 cat1 d 4 dog[2 rows x 3 columns]>>>pd.concat([df1,df3]) letter number animal0 a 1 <NA>1 b 2 <NA>0 c 3 cat1 d 4 dog[4 rows x 3 columns]
Combine
DataFrameobjects with overlapping columnsand return only those that are shared by passinginnertothejoinkeyword argument.>>>pd.concat([df1,df3],join="inner") letter number0 a 11 b 20 c 31 d 4[4 rows x 2 columns]
- Parameters:
objs (list ofobjects) – Objects to concatenate. Any None objects will be dropped silently unlessthey are all None in which case a ValueError will be raised.
axis ({0 or'index',1 or'columns'},default 0) – The axis to concatenate along.
join ({'inner','outer'},default 'outer') – How to handle indexes on other axis (or axes).
ignore_index (bool,default False) – If True, do not use the index values along the concatenation axis. Theresulting axis will be labeled 0, …, n - 1. This is useful if you areconcatenating objects where the concatenation axis does not havemeaningful indexing information. Note the index values on the otheraxes are still respected in the join.
- Returns:
When concatenating all
Seriesalong the index (axis=0), aSeriesis returned. Whenobjscontains at least oneDataFrame, aDataFrameis returned.- Return type: