Files
docker-stacks/tests/all-spark-notebook/data/issue_1168.ipynb
Ayaz Salikhov ec1584d33d Fix notebooks
2022-03-16 01:16:08 +02:00

62 lines
1.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is a test for the issue [#1168](https://github.com/jupyter/docker-stacks/issues/1168)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pyspark.sql import SparkSession\n",
"\n",
"# Spark session & context\n",
"spark = SparkSession.builder.master(\"local\").getOrCreate()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = spark.createDataFrame([(1, 21), (2, 30)], (\"id\", \"age\"))\n",
"\n",
"\n",
"def filter_func(iterator):\n",
" for pdf in iterator:\n",
" yield pdf[pdf.id == 1]\n",
"\n",
"\n",
"df.mapInPandas(filter_func, df.schema).show()"
]
}
],
"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.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 4
}