Skip to content

Instantly share code, notes, and snippets.

@brandon-b-miller
Created April 29, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandon-b-miller/9ab28b40c63a23b071bb13d326c88b2d to your computer and use it in GitHub Desktop.
Save brandon-b-miller/9ab28b40c63a23b071bb13d326c88b2d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3445362e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 4\n",
"1 6\n",
"2 8\n",
"dtype: int64\n"
]
}
],
"source": [
"import cudf\n",
"\n",
"df = cudf.DataFrame({\n",
" 'a': [1,2,3],\n",
" 'b': [4,5,6]\n",
"})\n",
"\n",
"def f(row):\n",
" x = row['a']\n",
" y = row['b']\n",
"\n",
" return x + y - 1\n",
"\n",
"result = df.apply(f, axis=1)\n",
"print(result)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment