<jupyter_start><jupyter_text>Create RDD from collection<jupyter_code>brands = ['Tesla','Ford','GM']
brandsRDD = sc.parallelize(brands,8)
brandsRDD.getNumPartitions()<jupyter_output><empty_output><jupyter_text>Create RDD from datasource<jupyter_code>n = 'https://raw.githubusercontent.com/uwdata/draco/master/data/cars.csv'
f = 'cars.csv'

sc.addFile(n)
data = spark.read.option("header", True).option("inferSchema", "true").csv(pyspark.SparkFiles.get(f))
data.count()
data.take(3)<jupyter_output><empty_output><jupyter_text>Create RDD from DataFrame<jupyter_code>dataFrame = spark.range(100).toDF('id')
dataFrame.take(2)
rdd = dataFrame.toDF('id').rdd
rdd.take(2)
rdd.count()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1702127659574468, 'fraction_numerical': 0.009929078014184398, 'mean_word_length': 9.537313432835822, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '68303', 'license': 'Apache-2.0', 'n_tokens_mistral': 294, 'n_tokens_neox': 286, 'n_words': 30, 'path': 'spark/basicrdd.ipynb', 'repo_name': 'stanislawbartkowski/learnml', 'size': '705'}