Create a Python function in DataLab server.
def csv2parquet(input_file: Path, /) -> dict[str, Path]:
"""Convert a CSV file to Parquet format.
:param input_file: Path to the input CSV file.
:return: Dict with 'parquet' key containing the output Parquet file path.
"""
# Read the CSV file
df = pd.read_csv(input_file)
# Define the output path with .parquet extension
parquet_path = input_file.with_suffix(".parquet")
# Write the DataFrame to a Parquet file
df.to_parquet(parquet_path, index=False)
return {"parquet": parquet_path}
# Create the csv2parquet function on the platform
func_def = gfhub.Function(csv2parquet, dependencies={'pandas[pyarrow]': 'import pandas as pd'})
result = client.add_function(func_def)
print(result)
{'id': '019bb972-1978-7b11-a786-1a35c71ebc93', 'name': 'csv2parquet', 'parameters': {}, 'inputs': {'input_file': {'type': 'Path'}}, 'outputs': {'parquet': {'type': 'Path'}}, 'created_at': '2026-01-13T22:20:21.240862Z', 'updated_at': '2026-01-14T10:24:04.382136Z'}