Skip to main content

A package for commonly used functions

Project description

PYCOF (PYthon COmmon Functions)

1. Installation

Downloads PyPI version

You can get pycof from PyPI with:

pip install pycof

The library is supported on Windows, Linux and MacOs.

2. Usage

2.1. Documentation

You can find the full documentation at or by clicking on the name of each function in the next section. It will redirect you the the function's specific documentation.

2.1. Available functions

The current version of the library provides:

  • verbose_display: extended function to print strings, lists, data frames and progression bar if used as a wrapper in for loops.
  • remote_execute_sql: aggragated function for SQL queries to SELECT, INSERT, DELETE or COPY.
  • f_read: Load any data file, regarless of the format.
  • send_email: simple function to send email to contacts in a concise way.
  • add_zero: simple function to convert int to str by adding a 0 is less than 10.
  • OneHotEncoding: performs One Hot Encoding on a dataframe for the provided column names. Will keep the original categorical variables if drop is set to False.
  • create_dataset: function to format a Pandas dataframe for keras format for LSTM.
  • group: will convert an int to a str with thousand seperator.
  • replace_zero: will transform 0 values to - for display purposes.
  • week_sunday: will return week number of last sunday date of a given date.
  • display_name: displays the current user name. Will display either first, last or full name.
  • write: writes a str to a specific file (usually .txt) in one line of code.
  • file_age: computes the age (in days, hours, ...) of a given local file.
  • str2bool: converts string to boolean.

2.2. Config file for credentials

The function remote_execute_sql and send_email will by default look for the credentials located in /etc/config.json. On Windows, save the config file as C:/Windows/config.json.

The file follows the below structure:

	"DB_USER": "",
	"DB_HOST": "",
	"DB_PORT": "3306",
	"__COMMENT_1__": "Email specific, send_email"
	"EMAIL_USER": "",
	"EMAIL_SMTP": "",
	"EMAIL_PORT": "587"
	"__COMMENT_2__": "IAM specific, if useIAM=True in remote_execute_sql",
	"REGION": "eu-west-1"

On Unix based system, run:

sudo nano /etc/config.json

and paste the above json after filling the empty strings (pre-filled values are standard default values).

Reminder: To save the file, with nano press CTRL + O, confirm with y then CTRL + X to exit.

On Windows, use the path C:/Windows/config.json.

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 pycof, version 1.1.42
Filename, size File type Python version Upload date Hashes
Filename, size pycof-1.1.42-py3-none-any.whl (17.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pycof-1.1.42.tar.gz (16.4 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