{ "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": 6, "metadata": {}, "outputs": [], "source": [ "from pyspark.sql import SparkSession\n", "from pyspark.sql.functions import pandas_udf\n", "\n", "# Spark session & context\n", "spark = SparkSession.builder.master('local').getOrCreate()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+---+---+\n", "| id|age|\n", "+---+---+\n", "| 1| 21|\n", "+---+---+\n", "\n" ] } ], "source": [ "df = spark.createDataFrame([(1, 21), (2, 30)], (\"id\", \"age\"))\n", "def filter_func(iterator):\n", " for pdf in iterator:\n", " yield pdf[pdf.id == 1]\n", "\n", "df.mapInPandas(filter_func, df.schema).show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6" } }, "nbformat": 4, "nbformat_minor": 4 }