A small example package
Project description
This is demo File. Aakash Aggarwal
Data transformations with Python
This is a collection of Python jobs that are supposed to transform data.
These jobs are using PySpark to process larger volumes of data and are supposed to run on a Spark cluster (via spark-submit).
Pre-requisites
Please make sure you have the following installed and can run them
- Python (3.6 or later)
- Pipenv
- Java (1.8 or later)
Install all dependencies
pipenv install
Run tests
Run unit tests
pipenv run unit-test
Run integration tests
pipenv run integration-test
Create .egg package
pipenv run packager
Use linter
pipenv run linter
Jobs
Sample
A Hello World Program
There is a dump of the datalake for this under resources/word_count/words.txt with a text file.
Input
Simple *.txt file containing text.
Output
A single *.csv file containing data similar to:
"word","count"
"a","3"
"an","5"
...
Run the job
Please make sure to package the code before submitting the spark job (pipenv run packager)
pipenv run spark-submit \
--master local \
--py-files dist/data_transformations-0.1.0-py3.6.egg \
jobs/word_count.py \
<INPUT_FILE_PATH> \
<OUTPUT_PATH>
Citibike
For analytics purposes the BI department of a bike share company would like to present dashboards, displaying the
distance each bike was driven. There is a *.csv file that contains historical data of previous bike rides. This input
file needs to be processed in multiple steps. There is a pipeline running these jobs.
There is a dump of the datalake for this under resources/citibike/citibike.csv with historical data.
Ingest
Reads a *.csv file and transforms it to parquet format. The column names will be sanitized (whitespaces replaced).
Input
Historical bike ride *.csv file:
"tripduration","starttime","stoptime","start station id","start station name","start station latitude",...
364,"2017-07-01 00:00:00","2017-07-01 00:06:05",539,"Metropolitan Ave & Bedford Ave",40.71534825,...
...
Output
*.parquet files containing the same content
"tripduration","starttime","stoptime","start_station_id","start_station_name","start_station_latitude",...
364,"2017-07-01 00:00:00","2017-07-01 00:06:05",539,"Metropolitan Ave & Bedford Ave",40.71534825,...
...
Run the job
Please make sure to package the code before submitting the spark job (pipenv run packager)
pipenv run spark-submit \
--master local \
--py-files dist/data_transformations-0.1.0-py3.6.egg \
jobs/citibike_ingest.py \
<INPUT_FILE_PATH> \
<OUTPUT_PATH>
Distance calculation
This job takes bike trip information and calculates the "as the crow flies" distance traveled for each trip. It reads the previously ingested data parquet files.
Hint:
- For distance calculation, consider using Harvesine formula as an option.
Input
Historical bike ride *.parquet files
"tripduration",...
364,...
...
Outputs
*.parquet files containing historical data with distance column containing the calculated distance.
"tripduration",...,"distance"
364,...,1.34
...
Run the job
Please make sure to package the code before submitting the spark job (pipenv run packager)
pipenv run spark-submit \
--master local \
--py-files dist/data_transformations-0.1.0-py3.6.egg \
jobs/citibike_distance_calculation.py \
<INPUT_PATH> \
<OUTPUT_PATH>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Demo-example-pkg-0.0.3.tar.gz.
File metadata
- Download URL: Demo-example-pkg-0.0.3.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/2.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00f36b539813830707e3b6e8186bbf3a3b7572db5752b86ed8e81570d719bafb
|
|
| MD5 |
d821513374582080704da5abee2d3a6f
|
|
| BLAKE2b-256 |
c17503982269013dc5de8d63ab5464f5df6261e68028e1ad1725f7daa432902b
|
File details
Details for the file Demo_example_pkg-0.0.3-py2-none-any.whl.
File metadata
- Download URL: Demo_example_pkg-0.0.3-py2-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/2.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bc97c02688d7ea420cf4abae9b0aee78aabb0bbe331e3a3494ec684a194ec99
|
|
| MD5 |
f1edb92569057212d2bb8a4add0674dc
|
|
| BLAKE2b-256 |
bebb0d017cffb582e26c22ba7fdc938428ad5a8bbdbfda022ec2c3853d22a366
|