All Projects → tirthajyoti → Spark With Python

tirthajyoti / Spark With Python

Licence: mit
Fundamentals of Spark with Python (using PySpark), code examples

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Spark With Python

aut
The Archives Unleashed Toolkit is an open-source toolkit for analyzing web archives.
Stars: ✭ 111 (-26%)
Mutual labels:  big-data, spark, apache-spark, hadoop, pyspark, dataframe
leaflet heatmap
简单的可视化湖州通话数据 假设数据量很大,没法用浏览器直接绘制热力图,把绘制热力图这一步骤放到线下计算分析。使用Apache Spark并行计算数据之后,再使用Apache Spark绘制热力图,然后用leafletjs加载OpenStreetMap图层和热力图图层,以达到良好的交互效果。现在使用Apache Spark实现绘制,可能是Apache Spark不擅长这方面的计算或者是我没有设计好算法,并行计算的速度比不上单机计算。Apache Spark绘制热力图和计算代码在这 https://github.com/yuanzhaokang/ParallelizeHeatmap.git .
Stars: ✭ 13 (-91.33%)
Mutual labels:  big-data, spark, apache-spark, hadoop, hdfs
Hive
Apache Hive
Stars: ✭ 4,031 (+2587.33%)
Mutual labels:  sql, big-data, hadoop, database, apache
Trino
Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
Stars: ✭ 4,581 (+2954%)
Mutual labels:  sql, analytics, big-data, hadoop, database
Griffon Vm
Griffon Data Science Virtual Machine
Stars: ✭ 128 (-14.67%)
Mutual labels:  jupyter-notebook, big-data, hadoop, apache-spark, database
Geni
A Clojure dataframe library that runs on Spark
Stars: ✭ 152 (+1.33%)
Mutual labels:  parallel-computing, dataframe, spark, big-data, distributed-computing
datalake-etl-pipeline
Simplified ETL process in Hadoop using Apache Spark. Has complete ETL pipeline for datalake. SparkSession extensions, DataFrame validation, Column extensions, SQL functions, and DataFrame transformations
Stars: ✭ 39 (-74%)
Mutual labels:  big-data, apache-spark, hadoop, pyspark
bigdata-fun
A complete (distributed) BigData stack, running in containers
Stars: ✭ 14 (-90.67%)
Mutual labels:  big-data, spark, hadoop, hdfs
Spark Py Notebooks
Apache Spark & Python (pySpark) tutorials for Big Data Analysis and Machine Learning as IPython / Jupyter notebooks
Stars: ✭ 1,338 (+792%)
Mutual labels:  jupyter-notebook, spark, big-data, pyspark
Crate
CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of data in real-time.
Stars: ✭ 3,254 (+2069.33%)
Mutual labels:  sql, analytics, big-data, database
Metorikku
A simplified, lightweight ETL Framework based on Apache Spark
Stars: ✭ 361 (+140.67%)
Mutual labels:  sql, spark, big-data, distributed-computing
Bigdata Notes
大数据入门指南 ⭐
Stars: ✭ 10,991 (+7227.33%)
Mutual labels:  spark, big-data, hadoop, hdfs
Devops Python Tools
80+ DevOps & Data CLI Tools - AWS, GCP, GCF Python Cloud Function, Log Anonymizer, Spark, Hadoop, HBase, Hive, Impala, Linux, Docker, Spark Data Converters & Validators (Avro/Parquet/JSON/CSV/INI/XML/YAML), Travis CI, AWS CloudFormation, Elasticsearch, Solr etc.
Stars: ✭ 406 (+170.67%)
Mutual labels:  spark, hadoop, pyspark, hdfs
Agile data code 2
Code for Agile Data Science 2.0, O'Reilly 2017, Second Edition
Stars: ✭ 413 (+175.33%)
Mutual labels:  jupyter-notebook, spark, analytics, apache-spark
pyspark-algorithms
PySpark Algorithms Book: https://www.amazon.com/dp/B07X4B2218/ref=sr_1_2
Stars: ✭ 72 (-52%)
Mutual labels:  big-data, distributed-computing, pyspark, dataframe
Live log analyzer spark
Spark Application for analysis of Apache Access logs and detect anamolies! Along with Medium Article.
Stars: ✭ 14 (-90.67%)
Mutual labels:  spark, analytics, apache-spark, pyspark
Azure Cosmosdb Spark
Apache Spark Connector for Azure Cosmos DB
Stars: ✭ 165 (+10%)
Mutual labels:  jupyter-notebook, spark, apache-spark, pyspark
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (+16.67%)
Mutual labels:  jupyter-notebook, sql, analytics, database
Ignite
Apache Ignite
Stars: ✭ 4,027 (+2584.67%)
Mutual labels:  sql, big-data, hadoop, database
H2o 3
H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.
Stars: ✭ 5,656 (+3670.67%)
Mutual labels:  jupyter-notebook, spark, big-data, hadoop

Spark with Python

Apache Spark

Apache Spark is one of the hottest new trends in the technology domain. It is the framework with probably the highest potential to realize the fruit of the marriage between Big Data and Machine Learning. It runs fast (up to 100x faster than traditional Hadoop MapReduce due to in-memory operation, offers robust, distributed, fault-tolerant data objects (called RDD), and integrates beautifully with the world of machine learning and graph analytics through supplementary packages like Mlib and GraphX.

Spark is implemented on Hadoop/HDFS and written mostly in Scala, a functional programming language, similar to Java. In fact, Scala needs the latest Java installation on your system and runs on JVM. However, for most of the beginners, Scala is not a language that they learn first to venture into the world of data science. Fortunately, Spark provides a wonderful Python integration, called PySpark, which lets Python programmers to interface with the Spark framework and learn how to manipulate data at scale and work with objects and algorithms over a distributed file system.

Notebooks

RDD and basics

Dataframe

Setting up Apache Spark with Python 3 and Jupyter notebook

Unlike most Python libraries, getting PySpark to start working properly is not as straightforward as pip install ... and import ... Most of us with Python-based data science and Jupyter/IPython background take this workflow as granted for all popular Python packages. We tend to just head over to our CMD or BASH shell, type the pip install command, launch a Jupyter notebook and import the library to start practicing.

But, PySpark+Jupyter combo needs a little bit more love :-)


Check which version of Python is running. Python 3.4+ is needed.

python3 --version

Update apt-get

sudo apt-get update

Install pip3 (or pip for Python3)

sudo apt install python3-pip

Install Jupyter for Python3

pip3 install jupyter

Augment the PATH variable to launch Jupyter notebook

export PATH=$PATH:~/.local/bin

Java 8 is shown to work with UBUNTU 18.04 LTS/SPARK-2.3.1-BIN-HADOOP2.7

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

Set Java related PATH variables

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre

Install Scala

sudo apt-get install scala

Install py4j for Python-Java integration

pip3 install py4j

Download latest Apache Spark (with pre-built Hadoop) from Apache download server. Unpack Apache Spark after downloading

sudo tar -zxvf spark-2.3.1-bin-hadoop2.7.tgz

Set variables to launch PySpark with Python3 and enable it to be called from Jupyter notebook. Add all the following lines to the end of your .bashrc file

export SPARK_HOME='/home/tirtha/Spark/spark-2.3.1-bin-hadoop2.7'
export PYTHONPATH=$SPARK_HOME/python:$PYTHONPATH
export PYSPARK_DRIVER_PYTHON="jupyter"
export PYSPARK_DRIVER_PYTHON_OPTS="notebook"
export PYSPARK_PYTHON=python3
export PATH=$SPARK_HOME:$PATH:~/.local/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

Source .bashrc

source .bashrc

Basics of RDD

Resilient Distributed Datasets (RDD) is a fundamental data structure of Spark. It is an immutable distributed collection of objects. Each dataset in RDD is divided into logical partitions, which may be computed on different nodes of the cluster. RDDs can contain any type of Python, Java, or Scala objects, including user-defined classes.

Spark makes use of the concept of RDD to achieve faster and efficient MapReduce operations.

Formally, an RDD is a read-only, partitioned collection of records. RDDs can be created through deterministic operations on either data on stable storage or other RDDs. RDD is a fault-tolerant collection of elements that can be operated on in parallel.

There are two ways to create RDDs,

  • parallelizing an existing collection in your driver program,
  • referencing a dataset in an external storage system, such as a shared file system, HDFS, HBase, or any data source offering a Hadoop Input Format.

Basics of the Dataframe

DataFrame

In Apache Spark, a DataFrame is a distributed collection of rows under named columns. It is conceptually equivalent to a table in a relational database, an Excel sheet with Column headers, or a data frame in R/Python, but with richer optimizations under the hood. DataFrames can be constructed from a wide array of sources such as: structured data files, tables in Hive, external databases, or existing RDDs. It also shares some common characteristics with RDD:

  • Immutable in nature : We can create DataFrame / RDD once but can’t change it. And we can transform a DataFrame / RDD after applying transformations.
  • Lazy Evaluations: Which means that a task is not executed until an action is performed.
  • Distributed: RDD and DataFrame both are distributed in nature.

Advantages of the Dataframe

  • DataFrames are designed for processing large collection of structured or semi-structured data.
  • Observations in Spark DataFrame are organised under named columns, which helps Apache Spark to understand the schema of a DataFrame. This helps Spark optimize execution plan on these queries.
  • DataFrame in Apache Spark has the ability to handle petabytes of data.
  • DataFrame has a support for wide range of data format and sources.
  • It has API support for different languages like Python, R, Scala, Java.

Spark SQL

Spark SQL provides a DataFrame API that can perform relational operations on both external data sources and Spark's built-in distributed collections—at scale!

To support a wide variety of diverse data sources and algorithms in Big Data, Spark SQL introduces a novel extensible optimizer called Catalyst, which makes it easy to add data sources, optimization rules, and data types for advanced analytics such as machine learning. Essentially, Spark SQL leverages the power of Spark to perform distributed, robust, in-memory computations at massive scale on Big Data.

Spark SQL provides state-of-the-art SQL performance and also maintains compatibility with all existing structures and components supported by Apache Hive (a popular Big Data warehouse framework) including data formats, user-defined functions (UDFs), and the metastore. Besides this, it also helps in ingesting a wide variety of data formats from Big Data sources and enterprise data warehouses like JSON, Hive, Parquet, and so on, and performing a combination of relational and procedural operations for more complex, advanced analytics.

Spark-2

Speed of Spark SQL

Spark SQL has been shown to be extremely fast, even comparable to C++ based engines such as Impala.

spark_speed

Following graph shows a nice benchmark result of DataFrames vs. RDDs in different languages, which gives an interesting perspective on how optimized DataFrames can be.

spark-speed-2

Why is Spark SQL so fast and optimized? The reason is because of a new extensible optimizer, Catalyst, based on functional programming constructs in Scala.

Catalyst's extensible design has two purposes.

  • Makes it easy to add new optimization techniques and features to Spark SQL, especially to tackle diverse problems around Big Data, semi-structured data, and advanced analytics
  • Ease of being able to extend the optimizer—for example, by adding data source-specific rules that can push filtering or aggregation into external storage systems or support for new data types
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].