A collection of one-off functions I use for various tasks as a Data Scientist-- if it ain't broke, don't fix it.
Project description
nojazz
A collection of one-off functions I use for various tasks as a Data Scientist-- if it ain't broke, don't fix it.
Name inspired by my favorite Pearls Before Swine comic
Disclaimer: I also like jazz
Installation
nojazz is hosted on PyPI and can be installed with a simple
pip install nojazz
Features
As mentioned above, I finally sat down to make this package after noticing that I was copying a lot of the same helper methods from project to project. To that end, nojazz is hardly comprehensive (nor necessarily related, submodule to submodule) but has a few, small "figured it out once and packaged it for reuse" utilities for:
sqlite3
My first and biggest re-use culprit. nojazz provides a simple context manager to allow that handles all of the connection/commit/closing of sqlite database functions.
with connect_to_db('test.db') as cursor:
cursor.execute('some sql')
Note, this will generate a nojazz_conf.py at the root of your project when calling. The library uses this to read the directory location for all of these database connections (i.e. on another drive, perhaps)
pandas
There are all kinds of tricks to this library. For now, nojazz provides the following helper methods
fill_time_series_nulls
For a given dataset with rows: agents and columns: observations, there are applications where want to consider NULL values as 0, but only after the user has shown up for the first time. This function does this, at the row-level and returns a copy of the original DataFrame. For example
0 1 2 3 4
0 1 NaN NaN 1 NaN
1 NaN NaN 1 NaN 1
transforms to
0 1 2 3 4
0 1 0 0 1 NaN
1 NaN NaN 1 0 1
realign_nonnull_data
Similar to fill_time_series_nulls, this function is used when you want to line all of your records up to the same starting period. Like so
0 1 2 3
0 NaN NaN NaN 1
1 NaN NaN 1 1
2 NaN 1 1 1
transforms to
0 1 2 3
0 1 NaN NaN NaN
1 1 1 NaN NaN
2 1 1 1 NaN
Note, this likely means needing to rename the columns to something more appropriate. Furthermore, we maintained the shape of the original DataFrame by padding all extra fields with NaN
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 nojazz-0.0.3.tar.gz.
File metadata
- Download URL: nojazz-0.0.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3092c14c21a23bb646cc726a8e784b3b6ceb113b32a4c8df081733ac5351ca55
|
|
| MD5 |
19fd1a8ff90a62318b2f8810105cf66c
|
|
| BLAKE2b-256 |
cbd249b4ee0dc507d80c73da72cba4ce24ecfdc9c9f4b9d06a70fbab7cbcbcd4
|
File details
Details for the file nojazz-0.0.3-py3-none-any.whl.
File metadata
- Download URL: nojazz-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
495474d0f5522e87a800fdea9a30d8e3a2b8edce9ba76405346355b3c1f491d2
|
|
| MD5 |
691c32496252c310add94c5ef59c5123
|
|
| BLAKE2b-256 |
02844f0e7e399895a13a6c17584cf3de65d8c3947d1237c77f6f93cff1b3f056
|