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.0.tar.gz
.
File metadata
- Download URL: datanerd-1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aff4ed9f79464067d48c10359a978a22969b8ca1f66ec75f9f4db906dbfab0d |
|
MD5 | 2a0fe1d78377a08ed8e0e85598173cff |
|
BLAKE2b-256 | f45f44b85c83d37f404063e0cc550adc306381385f4eba4ea60847b16ad3d06f |
File details
Details for the file datanerd-1.0-py3-none-any.whl
.
File metadata
- Download URL: datanerd-1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 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 | e3a421f2652e35b65129c3a0e69bb5cb2e5a68785b147160d767d274c0faa929 |
|
MD5 | 2b7c3b0d333a956ade6bc266cc2b6f7e |
|
BLAKE2b-256 | 548e7a4a2618350a3976ad1553dfb3a29826768e671d4b418f5a267300ad39d2 |