from pyspark.sql import SparkSession spark = SparkSession.builder.getOrCreate() dataList = [1, 2, 3, 4, 5] rdd = spark.sparkContext.parallelize(dataList) rdd2 = rdd.flatMap(lambda x: str(x)) data = rdd2.collect() for x in data: print(type(x), x)