bigframes.geopandas.GeoSeries.nlargest#

GeoSeries.nlargest(n:int=5,keep:str='first')Series#

Return the largestn elements.

Examples:

>>>importbigframes.pandasasbpd>>>countries_population={"Italy":59000000,"France":65000000,..."Malta":434000,"Maldives":434000,..."Brunei":434000,"Iceland":337000,..."Nauru":11300,"Tuvalu":11300,..."Anguilla":11300,"Montserrat":5200}>>>s=bpd.Series(countries_population)>>>sItaly         59000000France        65000000Malta           434000Maldives        434000Brunei          434000Iceland         337000Nauru            11300Tuvalu           11300Anguilla         11300Montserrat        5200dtype: Int64

The n largest elements wheren=5 by default.

>>>s.nlargest()France      65000000Italy       59000000Malta         434000Maldives      434000Brunei        434000dtype: Int64
The n largest elements wheren=3. Default keep value isfirst so Malta

will be kept.

>>>s.nlargest(3)France    65000000Italy     59000000Malta       434000dtype: Int64

The n largest elements wheren=3 and keeping the last duplicates. Bruneiwill be kept since it is the last with value 434000 based on the index order.

>>>s.nlargest(3,keep='last')France    65000000Italy     59000000Brunei      434000dtype: Int64

The n largest elements where n`=3` with all duplicates kept. Note that thereturned Series has five elements due to the three duplicates.

>>>s.nlargest(3,keep='all')France      65000000Italy       59000000Malta         434000Maldives      434000Brunei        434000dtype: Int64
Parameters:
  • n (int,default 5) – Return this many descending sorted values.

  • keep ({'first','last','all'},default 'first') – When there are duplicate values that cannot all fit in aSeries ofn elements:first : return the firstn occurrences in orderof appearance.last : return the lastn occurrences in reverseorder of appearance.all : keep all occurrences. This can result in a Series ofsize larger thann.

Returns:

Then largest values in the Series, sorted in decreasing order.

Return type:

bigframes.pandas.Series

This Page