class_docstr: Namespace for list related expressions.
class_docstr_tok: ["Namespace","for","list","related","expressions","."]
docstr: Sample from this list.
  
  Parameters
  ----------
  n
      Number of items to return. Cannot be used with `fraction`. Defaults to 1 if
      `fraction` is None.
  fraction
      Fraction of items to return. Cannot be used with `n`.
  with_replacement
      Allow values to be sampled more than once.
  shuffle
      Shuffle the order of sampled data points.
  seed
      Seed for the random number generator. If set to None (default), a
      random seed is generated for each sample operation.
  
  Examples
  --------
  >>> df = pl.DataFrame({"values": [[1, 2, 3], [4, 5]], "n": [2, 1]})
  >>> df.with_columns(sample=pl.col("values").list.sample(n=pl.col("n"), seed=1))
  shape: (2, 3)
  ┌───────────┬─────┬───────────┐
  │ values    ┆ n   ┆ sample    │
  │ ---       ┆ --- ┆ ---       │
  │ list[i64] ┆ i64 ┆ list[i64] │
  ╞═══════════╪═════╪═══════════╡
  │ [1, 2, 3] ┆ 2   ┆ [2, 1]    │
  │ [4, 5]    ┆ 1   ┆ [5]       │
  └───────────┴─────┴───────────┘
docstr_tok: ["Sample","from","this","list",".","Parameters","--","--","--","--","--","n","Number","of","items","to","return",".","Can","not","be","used","with","`","fraction","`",".","Defaults","to","1","if","`","fraction","`","is","None",".","fraction","Fraction","of","items","to","return",".","Can","not","be","used","with","`","n","`",".","with_replacement","Allow","values","to","be","sampled","more","than","once",".","shuffle","Shuffle","the","order","of","sampled","data","points",".","seed","Seed","for","the","random","number","generator",".","If","set","to","None","(","default",")",",","a","random","seed","is","generated","for","each","sample","operation",".","Examples","--","--","--","--",">",">",">","df","=","pl.DataFrame","(","{","``","values","''",":","[","[","1",",","2",",","3","]",",","[","4",",","5","]","]",",","``","n","''",":","[","2",",","1","]","}",")",">",">",">","df.with_columns","(","sample=pl.col","(","``","values","''",")",".list.sample","(","n=pl.col","(","``","n","''",")",",","seed=1",")",")","shape",":","(","2",",","3",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","values","\u2506","n","\u2506","sample","\u2502","\u2502","--","-","\u2506","--","-","\u2506","--","-","\u2502","\u2502","list","[","i64","]","\u2506","i64","\u2506","list","[","i64","]","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","[","1",",","2",",","3","]","\u2506","2","\u2506","[","2",",","1","]","\u2502","\u2502","[","4",",","5","]","\u2506","1","\u2506","[","5","]","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def sample(
      self,
      n: int | IntoExprColumn | None = None,
      *,
      fraction: float | IntoExprColumn | None = None,
      with_replacement: bool = False,
      shuffle: bool = False,
      seed: int | None = None,
  ) -> Expr:
      """
      Sample from this list.
  
      Parameters
      ----------
      n
          Number of items to return. Cannot be used with `fraction`. Defaults to 1 if
          `fraction` is None.
      fraction
          Fraction of items to return. Cannot be used with `n`.
      with_replacement
          Allow values to be sampled more than once.
      shuffle
          Shuffle the order of sampled data points.
      seed
          Seed for the random number generator. If set to None (default), a
          random seed is generated for each sample operation.
  
      Examples
      --------
      >>> df = pl.DataFrame({"values": [[1, 2, 3], [4, 5]], "n": [2, 1]})
      >>> df.with_columns(sample=pl.col("values").list.sample(n=pl.col("n"), seed=1))
      shape: (2, 3)
      ┌───────────┬─────┬───────────┐
      │ values    ┆ n   ┆ sample    │
      │ ---       ┆ --- ┆ ---       │
      │ list[i64] ┆ i64 ┆ list[i64] │
      ╞═══════════╪═════╪═══════════╡
      │ [1, 2, 3] ┆ 2   ┆ [2, 1]    │
      │ [4, 5]    ┆ 1   ┆ [5]       │
      └───────────┴─────┴───────────┘
  
      """
      if n is not None and fraction is not None:
          raise ValueError("cannot specify both `n` and `fraction`")
  
      if fraction is not None:
          fraction = parse_as_expression(fraction)
          return wrap_expr(
              self._pyexpr.list_sample_fraction(
                  fraction, with_replacement, shuffle, seed
              )
          )
  
      if n is None:
          n = 1
      n = parse_as_expression(n)
      return wrap_expr(
          self._pyexpr.list_sample_n(n, with_replacement, shuffle, seed)
      )
  
imports: from __future__ import annotations
  import copy
  from typing import TYPE_CHECKING, Any, Callable, Sequence
  import polars._reexport
  from polars import functions
  from polars.utils._parse_expr_input import parse_as_expression
  from polars.utils._wrap import wrap_expr
  from polars.utils.deprecation import deprecate_renamed_function, deprecate_renamed_parameter
label_desc: Use image node_id 7 for calling the ExprListNameSpace obj's underlying member method code with example usage: obj.sample(n) and returns: wrap_expr, wrap_expr