code: def test_sample():
      """Test the sample data transformer."""
      data = _create_dataframe(20)
      result = pipe(data, sample(n=10))
      assert len(result) == 10
      assert isinstance(result, pd.DataFrame)
      data = _create_data_with_values(20)
      result = sample(data, n=10)
      assert isinstance(result, dict)
      assert "values" in result
      assert len(result["values"]) == 10
      data = _create_dataframe(20)
      result = pipe(data, sample(frac=0.5))
      assert len(result) == 10
      assert isinstance(result, pd.DataFrame)
      data = _create_data_with_values(20)
      result = sample(data, frac=0.5)
      assert isinstance(result, dict)
      assert "values" in result
      assert len(result["values"]) == 10
  
file_path: altair/tests/utils/test_data.py
imports: import os
  import pytest
  import pandas
  from toolz import pipe
  from altair.utils.data import limit_rows, MaxRowsError, sample, to_values, to_json, to_csv
label_desc: Use image node_id 4 for calling a global function with example usage: test_sample() without return types