This release is a pre-release and may not be stable for production use.
e2fyi-pyspark
e2fyi-pyspark is an e2fyi namespaced python package with pyspark subpackage
(i.e. e2fyi.pyspark) which holds a collections of useful functions for common
but painful pyspark tasks.
API documentation can be found at https://e2fyi-pyspark.readthedocs.io/en/latest/.
Change logs are available in CHANGELOG.md.
- Python 3.6 and above
- Licensed under Apache-2.0.
Quickstart
pip install e2fyi-pyspark
Infer schema for unknown json strings inside a pyspark dataframe
e2fyi.pyspark.schema.infer_schema_from_rows is a util function to infer the
schema of unknown json strings inside a pyspark dataframe - i.e. so that the
schema can be subsequently used to parse the json string into a typed data
structure in the dataframe
(see pyspark.sql.functions.from_json).
import pyspark
from e2fyi.pyspark.schema import infer_schema_from_rows
# get spark session
spark = pyspark.sql.SparkSession.builder.getOrCreate()
# load a parquet (assume the parquet has a column "json_str", which
# contains a json str with unknown schema)
df = spark.read.parquet("s3://some-bucket/some-file.parquet")
# get 10% of the rows as sample (w/o replacement)
sample_rows = df.select("json_str").sample(False, 0.01).collect()
# infer the schema for json str in col "json_str" based on the sample rows
# NOTE: this is run locally (not in spark)
schema = infer_schema_from_rows(sample_rows, col="json_str")
# add a new column "data" which is the parsed json string with a inferred schema
df = df.withColumn("data", pyspark.sql.functions.from_json("json_str", schema))
# should have a column "data" with a proper schema
df.printSchema()
Metadata
Release files for e2fyi-pyspark 0.1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| e2fyi-pyspark-0.1.0a1.tar.gz | 8.8 kB | Without provenance | Details |
Release files / e2fyi-pyspark-0.1.0a1.tar.gz
| Download URL | e2fyi-pyspark-0.1.0a1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5803e03f99958c919d80296bb5924e0370dea959ac4fdfdb76d6a5d182197087
|
|
BLAKE2b-256 checksum How to use checksums |
9daf0377f641477d3cf1f259e30626e7ac05e7ddf3cef6c4490a8f82e83de205
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.1
|
Security for e2fyi-pyspark 0.1.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.