Skip to main content

The missing PySpark utils

Project description

The missing PySpark utils.


To install:

pip install pyspark-utils
# It also depends on absl-py.


import pyspark_utils.helper as spark_helper

# Nicely show rdd count and 3 items.
rdd = spark_helper.cache_and_log('MyRDD', rdd, 3)


import pyspark_utils.op as spark_op

# RDD<key, value>  ->  RDD<new_key, value> key: new_key))

# RDD<key, value>  ->  RDD<result> key, value: result))

# RDD<key, value>  ->  RDD<value, key>

# RDD<key, value>  ->  RDD<key, value> if func(key)
pair_rdd.filter(spark_op.filter_key(lambda key: true_or_false))

# RDD<key, value>  ->  RDD<key, value> if func(value)
pair_rdd.filter(spark_op.filter_value(lambda value: true_or_false))

# RDD<iteratable>  ->  RDD<tuple_or_list> with transformed values. elem: new_elem)) elem: new_elem))

# RDD<path>  ->  RDD<path> if path matches any given fnmatch-style patterns
rdd.filter(spark_op.filter_path(['*.txt', '*.csv', 'path/a.???']))

# RDD<element>  ->  RDD<element, element>

# RDD<key, value>   ->   RDD<key, value> with keys in key_rdd
spark_op.filter_keys(pair_rdd, key_rdd)

# RDD<key, value>   ->   RDD<key, value> with keys in whitelist and not in blacklist
spark_op.filter_keys(pair_rdd, whitelist_key_rdd, blacklist_key_rdd)

# RDD<key, value>   ->   RDD<key, value> with keys not in key_rdd
spark_op.substract_keys(pair_rdd, key_rdd)

# RDD<element>   ->   RDD<element> where element is not None

# RDD<key>   ->   RDD<key, value> key: value))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyspark-utils, version 1.8.0
Filename, size File type Python version Upload date Hashes
Filename, size pyspark_utils-1.8.0-py2-none-any.whl (4.7 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size pyspark_utils-1.8.0-py3-none-any.whl (7.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyspark_utils-1.8.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page