bigframes.pandas.Series.reset_index#
- Series.reset_index(level:blocks.LevelsType=None,*,name:Optional[str]=None,drop:Literal[False]=False,inplace:Literal[False]=False,allow_duplicates:bool|None=None)→bigframes.dataframe.DataFrame[source]#
- Series.reset_index(level:blocks.LevelsType=None,*,name:Optional[str]=None,drop:Literal[True]=False,inplace:Literal[False]=False,allow_duplicates:bool|None=None)→Series
- Series.reset_index(level:blocks.LevelsType=None,*,name:Optional[str]=None,drop:bool=False,inplace:Literal[True]=False,allow_duplicates:bool|None=None)→None
Generate a new DataFrame or Series with the index reset.
This is useful when the index needs to be treated as a column, orwhen the index is meaningless and needs to be reset to the defaultbefore another operation.
Examples:
>>>s=bpd.Series([1,2,3,4],name='foo',...index=['a','b','c','d'])>>>s.index.name="idx">>>sidxa 1b 2c 3d 4Name: foo, dtype: Int64
Generate a DataFrame with default index.
>>>s.reset_index() idx foo0 a 11 b 22 c 33 d 4[4 rows x 2 columns]
To specify the name of the new column use
nameparam.>>>s.reset_index(name="bar") idx bar0 a 11 b 22 c 33 d 4[4 rows x 2 columns]
To generate a new Series with the default index set param
drop=True.>>>s.reset_index(drop=True)0 11 22 33 4Name: foo, dtype: Int64
>>>arrays=[np.array(['bar','bar','baz','baz']),...np.array(['one','two','one','two'])]>>>s2=bpd.Series(...range(4),name='foo',...index=pd.MultiIndex.from_arrays(arrays,...names=['a','b']))
If level is not set, all levels are removed from the Index.
>>>s2.reset_index() a b foo0 bar one 01 bar two 12 baz one 23 baz two 3[4 rows x 3 columns]
- Parameters:
level (int,str,tuple, orlist,default optional) – For a Series with a MultiIndex, only remove the specified levelsfrom the index. Removes all levels by default.
drop (bool,default False) – Just reset the index, without inserting it as a column inthe new DataFrame.
name (object,optional) – The name to use for the column containing the original Seriesvalues. Uses
self.nameby default. This argument is ignoredwhendrop is True.inplace (bool,default False) – Modify the Series in place (do not create a new object).
allow_duplicates (bool,optional,default None) – Allow duplicate column labels to be created.
- Returns:
Whendrop is False (the default),a DataFrame is returned. The newly created columns will come firstin the DataFrame, followed by the original Series values.Whendrop is True, aSeries is returned.In either case, if
inplace=True, no value is returned.- Return type:
bigframes.pandas.Series orbigframes.pandas.DataFrame or None