nodes: 0, module; 1, function_definition; 2, function_name:nsmallest; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, return_statement; 10, identifier:n; 11, integer:5; 12, identifier:keep; 13, string; 14, comment:"""
          Return the smallest `n` elements.
  
          Parameters
          ----------
          n : int, default 5
              Return this many ascending sorted values.
          keep : {'first', 'last', 'all'}, default 'first'
              When there are duplicate values that cannot all fit in a
              Series of `n` elements:
  
              - ``first`` : return the first `n` occurrences in order
                  of appearance.
              - ``last`` : return the last `n` occurrences in reverse
                  order of appearance.
              - ``all`` : keep all occurrences. This can result in a Series of
                  size larger than `n`.
  
          Returns
          -------
          Series
              The `n` smallest values in the Series, sorted in increasing order.
  
          See Also
          --------
          Series.nlargest: Get the `n` largest elements.
          Series.sort_values: Sort Series by values.
          Series.head: Return the first `n` rows.
  
          Notes
          -----
          Faster than ``.sort_values().head(n)`` for small `n` relative to
          the size of the ``Series`` object.
  
          Examples
          --------
          >>> countries_population = {"Italy": 59000000, "France": 65000000,
          ...                         "Brunei": 434000, "Malta": 434000,
          ...                         "Maldives": 434000, "Iceland": 337000,
          ...                         "Nauru": 11300, "Tuvalu": 11300,
          ...                         "Anguilla": 11300, "Monserat": 5200}
          >>> s = pd.Series(countries_population)
          >>> s
          Italy       59000000
          France      65000000
          Brunei        434000
          Malta         434000
          Maldives      434000
          Iceland       337000
          Nauru          11300
          Tuvalu         11300
          Anguilla       11300
          Monserat        5200
          dtype: int64
  
          The `n` smallest elements where ``n=5`` by default.
  
          >>> s.nsmallest()
          Monserat      5200
          Nauru        11300
          Tuvalu       11300
          Anguilla     11300
          Iceland     337000
          dtype: int64
  
          The `n` smallest elements where ``n=3``. Default `keep` value is
          'first' so Nauru and Tuvalu will be kept.
  
          >>> s.nsmallest(3)
          Monserat     5200
          Nauru       11300
          Tuvalu      11300
          dtype: int64
  
          The `n` smallest elements where ``n=3`` and keeping the last
          duplicates. Anguilla and Tuvalu will be kept since they are the last
          with value 11300 based on the index order.
  
          >>> s.nsmallest(3, keep='last')
          Monserat     5200
          Anguilla    11300
          Tuvalu      11300
          dtype: int64
  
          The `n` smallest elements where ``n=3`` with all duplicates kept. Note
          that the returned Series has four elements due to the three duplicates.
  
          >>> s.nsmallest(3, keep='all')
          Monserat     5200
          Nauru       11300
          Tuvalu      11300
          Anguilla    11300
          dtype: int64
          """; 15, call; 16, string_content:first; 17, attribute; 18, argument_list; 19, call; 20, identifier:nsmallest; 21, attribute; 22, argument_list; 23, identifier:algorithms; 24, identifier:SelectNSeries; 25, identifier:self; 26, keyword_argument; 27, keyword_argument; 28, identifier:n; 29, identifier:n; 30, identifier:keep; 31, identifier:keep
code: def nsmallest(self, n=5, keep='first'):
          """
          Return the smallest `n` elements.
  
          Parameters
          ----------
          n : int, default 5
              Return this many ascending sorted values.
          keep : {'first', 'last', 'all'}, default 'first'
              When there are duplicate values that cannot all fit in a
              Series of `n` elements:
  
              - ``first`` : return the first `n` occurrences in order
                  of appearance.
              - ``last`` : return the last `n` occurrences in reverse
                  order of appearance.
              - ``all`` : keep all occurrences. This can result in a Series of
                  size larger than `n`.
  
          Returns
          -------
          Series
              The `n` smallest values in the Series, sorted in increasing order.
  
          See Also
          --------
          Series.nlargest: Get the `n` largest elements.
          Series.sort_values: Sort Series by values.
          Series.head: Return the first `n` rows.
  
          Notes
          -----
          Faster than ``.sort_values().head(n)`` for small `n` relative to
          the size of the ``Series`` object.
  
          Examples
          --------
          >>> countries_population = {"Italy": 59000000, "France": 65000000,
          ...                         "Brunei": 434000, "Malta": 434000,
          ...                         "Maldives": 434000, "Iceland": 337000,
          ...                         "Nauru": 11300, "Tuvalu": 11300,
          ...                         "Anguilla": 11300, "Monserat": 5200}
          >>> s = pd.Series(countries_population)
          >>> s
          Italy       59000000
          France      65000000
          Brunei        434000
          Malta         434000
          Maldives      434000
          Iceland       337000
          Nauru          11300
          Tuvalu         11300
          Anguilla       11300
          Monserat        5200
          dtype: int64
  
          The `n` smallest elements where ``n=5`` by default.
  
          >>> s.nsmallest()
          Monserat      5200
          Nauru        11300
          Tuvalu       11300
          Anguilla     11300
          Iceland     337000
          dtype: int64
  
          The `n` smallest elements where ``n=3``. Default `keep` value is
          'first' so Nauru and Tuvalu will be kept.
  
          >>> s.nsmallest(3)
          Monserat     5200
          Nauru       11300
          Tuvalu      11300
          dtype: int64
  
          The `n` smallest elements where ``n=3`` and keeping the last
          duplicates. Anguilla and Tuvalu will be kept since they are the last
          with value 11300 based on the index order.
  
          >>> s.nsmallest(3, keep='last')
          Monserat     5200
          Anguilla    11300
          Tuvalu      11300
          dtype: int64
  
          The `n` smallest elements where ``n=3`` with all duplicates kept. Note
          that the returned Series has four elements due to the three duplicates.
  
          >>> s.nsmallest(3, keep='all')
          Monserat     5200
          Nauru       11300
          Tuvalu      11300
          Anguilla    11300
          dtype: int64
          """
          return algorithms.SelectNSeries(self, n=n, keep=keep).nsmallest()