code: def test_top_k() -> None:
      # expression
      s = pl.Series("a", [3, 8, 1, 5, 2])
  
      assert_series_equal(s.top_k(3), pl.Series("a", [8, 5, 3]))
      assert_series_equal(s.bottom_k(4), pl.Series("a", [1, 2, 3, 5]))
  
      assert_series_equal(
          s.top_k(pl.Series([3])), pl.Series("a", [8, 5, 3])
      )
      assert_series_equal(
          s.bottom_k(pl.Series([4])), pl.Series("a", [1, 2, 3, 5])
      )
  
      # 5886
      df = pl.DataFrame(
          {
              "test": [2, 4, 1, 3],
              "val": [2, 4, 9, 3],
          }
      )
      assert_frame_equal(
          df.select(pl.col("test").top_k(10)),
          pl.DataFrame({"test": [4, 3, 2, 1]}),
      )
  
      assert_frame_equal(
          df.select(
              top_k=pl.col("test").top_k(pl.col("val").min()),
              bottom_k=pl.col("test").bottom_k(pl.col("val").min()),
          ),
          pl.DataFrame({"top_k": [4, 3], "bottom_k": [1, 2]}),
      )
  
      # dataframe
      df = pl.DataFrame(
          {
              "a": [1, 2, 3, 4, 2, 2],
              "b": [3, 2, 1, 4, 3, 2],
          }
      )
  
      assert_frame_equal(
          df.top_k(3, by=["a", "b"]),
          pl.DataFrame({"a": [4, 3, 2], "b": [4, 1, 3]}),
      )
  
      assert_frame_equal(
          df.top_k(3, by=["a", "b"], descending=True),
          pl.DataFrame({"a": [1, 2, 2], "b": [3, 2, 2]}),
      )
      assert_frame_equal(
          df.bottom_k(4, by=["a", "b"], descending=True),
          pl.DataFrame({"a": [4, 3, 2, 2], "b": [4, 1, 3, 2]}),
      )
  
imports: from __future__ import annotations
  from datetime import date, datetime
  from typing import Any
  import pytest
  import polars
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 13 for calling a global function with example usage: test_top_k() without return types