<jupyter_start><jupyter_text>Установка через pip<jupyter_code>pip install pyspark
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("Test").getOrCreate()
spark.version<jupyter_output><empty_output><jupyter_text>Установка из исходников Чуть более сложная установка и настройка, однако более гибкая (можно выбрать любую версию Spark и Java)<jupyter_code>!apt-get install openjdk-8-jdk-headless -qq > /dev/null
!wget -q https://downloads.apache.org/spark/spark-3.1.2/spark-3.1.2-bin-hadoop3.2.tgz
!tar xf spark-3.1.2-bin-hadoop3.2.tgz
!pip install -q findspark
import os
os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-8-openjdk-amd64"
os.environ["SPARK_HOME"] = "/content/spark-3.1.2-bin-hadoop3.2"
import findspark
findspark.init()

from pyspark.sql import SparkSession
spark = SparkSession.builder.master("local[*]").getOrCreate()
spark.version<jupyter_output><empty_output><jupyter_text>Дополнительные фишки Google Colab<jupyter_code># Загрузка файла с локального диска

from google.colab import files
files.upload()
# примонтировать Google Drive

from google.colab import drive
drive.mount('/content/drive')<jupyter_output>Mounted at /content/drive
{'fraction_non_alphanumeric': 0.12211784799316823, 'fraction_numerical': 0.018787361229718188, 'mean_word_length': 6.279503105590062, 'pattern_counts': {'":': 0, '<': 12, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '166196', 'license': 'MIT', 'n_tokens_mistral': 468, 'n_tokens_neox': 476, 'n_words': 83, 'path': 'practice-1/notebooks/google_collab_pyspark.ipynb', 'repo_name': 'oleg-agapov/getting-started-with-pyspark-ru', 'size': '1171'}