Contains multiple functions stats(), iv_woe(), pushdb(), teams_webhook(), and ntfy()
Project description
DataNerd
This package provides various functions for data analysis, statistical calculations, database operations, and sending notifications.
Installation
To use these functions, you need to have Python installed on your system. You also need to install the required libraries. You can install them using pip:
pip install pandas numpy sqlalchemy requests
Functions
1. stats()
This function provides statistical summary of a given dataframe.
Parameters:
df
(pandas.DataFrame): The input dataframe
Returns:
- A dataframe containing various statistics for each column
Statistics provided:
- count
- mean
- std
- min
- 10th, 20th, 25th, 30th, 40th, 50th (median), 60th, 70th, 75th, 80th, 90th, 95th, 99th percentiles
- max
- % of missing values
- number of unique values
Usage:
import pandas as pd
import datanerd as dn
df = pd.read_csv('titanic.csv')
summary_stats = dn.stats(df)
2. iv_woe()
This function calculates the Weight of Evidence (WoE) and Information Value (IV) for a given dataframe.
Parameters:
data
(pandas.DataFrame): The input dataframetarget
(str): The name of the target variablebins
(int): The number of bins to use for discretizing continuous variablesoptimize
(bool): Whether to optimize the binning of continuous variablesthreshold
(float): The minimum percentage of non-events in each bin for optimization
Returns:
- A tuple containing two dataframes: (iv, woe)
Usage:
import pandas as pd
import datanerd as dn
df = pd.read_csv('cancer.csv')
iv, woe = dn.iv_woe(data=df, target='Diagnosis', bins=20, optimize=True, threshold=0.05)
3. pushdb()
This function pushes a Pandas dataframe to a Microsoft SQL Server database.
Parameters:
data
(pandas.DataFrame): The dataframe to be pushedtablename
(str): The name of the table in the databaseserver
(str): The name of the SQL Serverdatabase
(str): The name of the databaseschema
(str): The name of the schema
Usage:
import pandas as pd
import datanerd as dn
df = pd.read_csv('day.csv')
dn.pushdb(df, tablename='day', server='SQL', database='schedule', schema='analysis')
4. teams_webhook()
This function sends a formatted message to a Microsoft Teams channel using a webhook URL.
Parameters:
webhook_url
(str): The webhook URL for the Teams channeltitle
(str): The title of the messagemessage
(str): The body of the message
Usage:
import datanerd as dn
webhook_url = "https://outlook.office.com/webhook/..."
title = "Important Notification"
message = "This is a test message sent from Python!"
dn.teams_webhook(webhook_url, title, message)
5. ntfy()
This function sends a notification message to an ntfy.sh server.
Parameters:
server
(str): The name of the ntfy.sh server/topic to send the message tomessage
(str): The message to be sent
Usage:
import datanerd as dn
server = "your_server_name"
message = "This is a test notification from Python!"
dn.ntfy(server, message)
Project details
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
File details
Details for the file datanerd-1.1.tar.gz
.
File metadata
- Download URL: datanerd-1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74ddaca4ec6136001615c081c653762afadcd6f6e9cd0beb877be2ad88c9d873 |
|
MD5 | 6bc7e10f5d71319f4ad5edcf3af00f1a |
|
BLAKE2b-256 | 4df1e693c5893724d9cedd5b2a94f172d5fdea4bf3b4e60d0e404efb1debcdb3 |
File details
Details for the file datanerd-1.1-py3-none-any.whl
.
File metadata
- Download URL: datanerd-1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17bb79b0af4cf79d829631a73b9ccd92ce4490f40fbee0e100b4e01cbd30df73 |
|
MD5 | 7328ce9561cef61ebcdc8ac0349f6a3f |
|
BLAKE2b-256 | b8e415f1f541b5e970cfce3c6dc6f388b4835eb6fa4a188ce10a1b52cb25281c |