rgwfuncs 0.0.18__tar.gz → 0.0.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rgwfuncs-0.0.18/src/rgwfuncs.egg-info → rgwfuncs-0.0.20}/PKG-INFO +42 -5
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/README.md +41 -4
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/pyproject.toml +1 -1
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/setup.cfg +1 -1
- rgwfuncs-0.0.20/src/rgwfuncs/__init__.py +5 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs/df_lib.py +5 -13
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs/str_lib.py +46 -4
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20/src/rgwfuncs.egg-info}/PKG-INFO +42 -5
- rgwfuncs-0.0.18/src/rgwfuncs/__init__.py +0 -5
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/LICENSE +0 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs.egg-info/SOURCES.txt +0 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs.egg-info/dependency_links.txt +0 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs.egg-info/entry_points.txt +0 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs.egg-info/requires.txt +0 -0
- {rgwfuncs-0.0.18 → rgwfuncs-0.0.20}/src/rgwfuncs.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.20
|
4
4
|
Summary: A functional programming paradigm for mathematical modelling and data science
|
5
5
|
Home-page: https://github.com/ryangerardwilson/rgwfunc
|
6
6
|
Author: Ryan Gerard Wilson
|
@@ -28,7 +28,7 @@ Requires-Dist: google-api-python-client
|
|
28
28
|
|
29
29
|
***By Ryan Gerard Wilson (https://ryangerardwilson.com)***
|
30
30
|
|
31
|
-
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `
|
31
|
+
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `.rgwfuncsrc` file for certain features (like db querying, sending data to slack, etc.)
|
32
32
|
|
33
33
|
--------------------------------------------------------------------------------
|
34
34
|
|
@@ -135,11 +135,48 @@ To display all docstrings, use:
|
|
135
135
|
|
136
136
|
--------------------------------------------------------------------------------
|
137
137
|
|
138
|
-
##
|
138
|
+
## String Based Functions
|
139
|
+
|
140
|
+
### 1. str_docs
|
141
|
+
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
142
|
+
|
143
|
+
• Parameters:
|
144
|
+
- `method_type_filter` (str): Optional, comma-separated to select docstring types, or '*' for all.
|
145
|
+
|
146
|
+
• Example:
|
147
|
+
|
148
|
+
import rgwfuncs
|
149
|
+
rgwfuncs.str_docs(method_type_filter='numeric_clean,limit_dataframe')
|
150
|
+
|
151
|
+
--------------------------------------------------------------------------------
|
152
|
+
|
153
|
+
### 2. send_telegram_message
|
154
|
+
|
155
|
+
Send a message to a Telegram chat using a specified preset from your configuration file.
|
156
|
+
|
157
|
+
• Parameters:
|
158
|
+
- `preset_name` (str): The name of the preset to use for sending the message. This should match a preset in the configuration file.
|
159
|
+
- `message` (str): The message text that you want to send to the Telegram chat.
|
160
|
+
|
161
|
+
• Raises:
|
162
|
+
- `RuntimeError`: If the preset is not found in the configuration file or if necessary details (bot token or chat ID) are missing.
|
163
|
+
|
164
|
+
• Example:
|
165
|
+
|
166
|
+
from rgwfuncs import send_telegram_message
|
167
|
+
|
168
|
+
preset_name = "daily_updates"
|
169
|
+
message = "Here is your daily update!"
|
170
|
+
|
171
|
+
send_telegram_message(preset_name, message)
|
172
|
+
|
173
|
+
--------------------------------------------------------------------------------
|
174
|
+
|
175
|
+
## Dataframe Based Functions
|
139
176
|
|
140
177
|
Below is a quick reference of available functions, their purpose, and basic usage examples.
|
141
178
|
|
142
|
-
### 1.
|
179
|
+
### 1. df_docs
|
143
180
|
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
144
181
|
|
145
182
|
• Parameters:
|
@@ -148,7 +185,7 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
148
185
|
• Example:
|
149
186
|
|
150
187
|
import rgwfuncs
|
151
|
-
rgwfuncs.
|
188
|
+
rgwfuncs.df_docs(method_type_filter='numeric_clean,limit_dataframe')
|
152
189
|
|
153
190
|
--------------------------------------------------------------------------------
|
154
191
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
***By Ryan Gerard Wilson (https://ryangerardwilson.com)***
|
4
4
|
|
5
|
-
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `
|
5
|
+
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `.rgwfuncsrc` file for certain features (like db querying, sending data to slack, etc.)
|
6
6
|
|
7
7
|
--------------------------------------------------------------------------------
|
8
8
|
|
@@ -109,11 +109,48 @@ To display all docstrings, use:
|
|
109
109
|
|
110
110
|
--------------------------------------------------------------------------------
|
111
111
|
|
112
|
-
##
|
112
|
+
## String Based Functions
|
113
|
+
|
114
|
+
### 1. str_docs
|
115
|
+
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
116
|
+
|
117
|
+
• Parameters:
|
118
|
+
- `method_type_filter` (str): Optional, comma-separated to select docstring types, or '*' for all.
|
119
|
+
|
120
|
+
• Example:
|
121
|
+
|
122
|
+
import rgwfuncs
|
123
|
+
rgwfuncs.str_docs(method_type_filter='numeric_clean,limit_dataframe')
|
124
|
+
|
125
|
+
--------------------------------------------------------------------------------
|
126
|
+
|
127
|
+
### 2. send_telegram_message
|
128
|
+
|
129
|
+
Send a message to a Telegram chat using a specified preset from your configuration file.
|
130
|
+
|
131
|
+
• Parameters:
|
132
|
+
- `preset_name` (str): The name of the preset to use for sending the message. This should match a preset in the configuration file.
|
133
|
+
- `message` (str): The message text that you want to send to the Telegram chat.
|
134
|
+
|
135
|
+
• Raises:
|
136
|
+
- `RuntimeError`: If the preset is not found in the configuration file or if necessary details (bot token or chat ID) are missing.
|
137
|
+
|
138
|
+
• Example:
|
139
|
+
|
140
|
+
from rgwfuncs import send_telegram_message
|
141
|
+
|
142
|
+
preset_name = "daily_updates"
|
143
|
+
message = "Here is your daily update!"
|
144
|
+
|
145
|
+
send_telegram_message(preset_name, message)
|
146
|
+
|
147
|
+
--------------------------------------------------------------------------------
|
148
|
+
|
149
|
+
## Dataframe Based Functions
|
113
150
|
|
114
151
|
Below is a quick reference of available functions, their purpose, and basic usage examples.
|
115
152
|
|
116
|
-
### 1.
|
153
|
+
### 1. df_docs
|
117
154
|
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
118
155
|
|
119
156
|
• Parameters:
|
@@ -122,7 +159,7 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
122
159
|
• Example:
|
123
160
|
|
124
161
|
import rgwfuncs
|
125
|
-
rgwfuncs.
|
162
|
+
rgwfuncs.df_docs(method_type_filter='numeric_clean,limit_dataframe')
|
126
163
|
|
127
164
|
--------------------------------------------------------------------------------
|
128
165
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# This file is automatically generated
|
2
|
+
# Dynamically importing functions from modules
|
3
|
+
|
4
|
+
from .df_lib import append_columns, append_percentile_classification_column, append_ranged_classification_column, append_ranged_date_classification_column, append_rows, append_xgb_labels, append_xgb_logistic_regression_predictions, append_xgb_regression_predictions, bag_union_join, bottom_n_unique_values, cascade_sort, delete_rows, df_docs, drop_duplicates, drop_duplicates_retain_first, drop_duplicates_retain_last, filter_dataframe, filter_indian_mobiles, first_n_rows, from_raw_data, insert_dataframe_in_sqlite_database, last_n_rows, left_join, limit_dataframe, load_data_from_path, load_data_from_query, load_data_from_sqlite_path, mask_against_dataframe, mask_against_dataframe_converse, numeric_clean, order_columns, print_correlation, print_dataframe, print_memory_usage, print_n_frequency_cascading, print_n_frequency_linear, rename_columns, retain_columns, right_join, send_data_to_email, send_data_to_slack, send_dataframe_via_telegram, sync_dataframe_to_sqlite_database, top_n_unique_values, union_join, update_rows
|
5
|
+
from .str_lib import send_telegram_message, str_docs
|
@@ -29,7 +29,7 @@ import warnings
|
|
29
29
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
30
30
|
|
31
31
|
|
32
|
-
def
|
32
|
+
def df_docs(method_type_filter: Optional[str] = None) -> None:
|
33
33
|
"""
|
34
34
|
Print a list of function names in alphabetical order. If method_type_filter
|
35
35
|
is specified, print the docstrings of the functions that match the filter.
|
@@ -1673,21 +1673,16 @@ def print_n_frequency_cascading(
|
|
1673
1673
|
print(json.dumps(report, indent=2))
|
1674
1674
|
|
1675
1675
|
|
1676
|
-
def print_n_frequency_linear(
|
1677
|
-
df: pd.DataFrame,
|
1678
|
-
n: int,
|
1679
|
-
columns: str,
|
1680
|
-
order_by: str = "FREQ_DESC") -> None:
|
1676
|
+
def print_n_frequency_linear(df: pd.DataFrame, n: int, columns: list, order_by: str = "FREQ_DESC") -> None:
|
1681
1677
|
"""
|
1682
1678
|
Print the linear frequency of top n values for specified columns.
|
1683
1679
|
|
1684
1680
|
Parameters:
|
1685
1681
|
df: DataFrame to analyze.
|
1686
1682
|
n: Number of top values to print.
|
1687
|
-
columns:
|
1688
|
-
order_by: Order of frequency:
|
1683
|
+
columns: List of column names to analyze.
|
1684
|
+
order_by: Order of frequency: ASC, DESC, FREQ_ASC, FREQ_DESC.
|
1689
1685
|
"""
|
1690
|
-
columns = [col.strip() for col in columns.split(",")]
|
1691
1686
|
|
1692
1687
|
def generate_linear_report(df, columns, limit, order_by):
|
1693
1688
|
report = {}
|
@@ -1942,10 +1937,7 @@ def insert_dataframe_in_sqlite_database(db_path: str, tablename: str, df: pd.Dat
|
|
1942
1937
|
df.to_sql(tablename, conn, if_exists='append', index=False)
|
1943
1938
|
|
1944
1939
|
|
1945
|
-
def sync_dataframe_to_sqlite_database(
|
1946
|
-
db_path: str,
|
1947
|
-
tablename: str,
|
1948
|
-
df: pd.DataFrame) -> None:
|
1940
|
+
def sync_dataframe_to_sqlite_database(db_path: str, tablename: str, df: pd.DataFrame) -> None:
|
1949
1941
|
"""
|
1950
1942
|
Processes and saves a DataFrame to an SQLite database, adding a timestamp column
|
1951
1943
|
and replacing the existing table if needed. Creates the table if it does not exist.
|
@@ -1,7 +1,50 @@
|
|
1
1
|
import os
|
2
2
|
import json
|
3
3
|
import requests
|
4
|
-
|
4
|
+
import inspect
|
5
|
+
from typing import Tuple, Optional, Dict, Callable
|
6
|
+
import warnings
|
7
|
+
|
8
|
+
# Suppress all FutureWarnings
|
9
|
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
10
|
+
|
11
|
+
|
12
|
+
def str_docs(method_type_filter: Optional[str] = None) -> None:
|
13
|
+
"""
|
14
|
+
Print a list of function names in alphabetical order. If method_type_filter
|
15
|
+
is specified, print the docstrings of the functions that match the filter.
|
16
|
+
Using '*' as a filter will print the docstrings for all functions.
|
17
|
+
|
18
|
+
Parameters:
|
19
|
+
method_type_filter: Optional filter string representing a function name,
|
20
|
+
or '*' to display docstrings for all functions.
|
21
|
+
"""
|
22
|
+
# Get the current module's namespace
|
23
|
+
current_module = __name__
|
24
|
+
|
25
|
+
local_functions: Dict[str, Callable] = {
|
26
|
+
name: obj for name, obj in globals().items()
|
27
|
+
if inspect.isfunction(obj) and obj.__module__ == current_module
|
28
|
+
}
|
29
|
+
|
30
|
+
# List of function names sorted alphabetically
|
31
|
+
function_names = sorted(local_functions.keys())
|
32
|
+
|
33
|
+
# Print function names
|
34
|
+
print("Functions in alphabetical order:")
|
35
|
+
for name in function_names:
|
36
|
+
print(name)
|
37
|
+
|
38
|
+
# If a filter is provided or '*', print the docstrings of functions
|
39
|
+
if method_type_filter:
|
40
|
+
# print("\nFiltered function documentation:")
|
41
|
+
for name, func in local_functions.items():
|
42
|
+
docstring: Optional[str] = func.__doc__
|
43
|
+
if docstring:
|
44
|
+
if method_type_filter == '*' or method_type_filter == name:
|
45
|
+
# Print the entire docstring for the matching function
|
46
|
+
print(f"\n{name}:\n{docstring}")
|
47
|
+
|
5
48
|
|
6
49
|
def send_telegram_message(preset_name: str, message: str) -> None:
|
7
50
|
"""Send a Telegram message using the specified preset.
|
@@ -48,10 +91,10 @@ def send_telegram_message(preset_name: str, message: str) -> None:
|
|
48
91
|
|
49
92
|
# Load the configuration
|
50
93
|
config = load_config()
|
51
|
-
|
94
|
+
|
52
95
|
# Get bot details from the configuration
|
53
96
|
bot_token, chat_id = get_telegram_bot_details(config, preset_name)
|
54
|
-
|
97
|
+
|
55
98
|
# Prepare the request
|
56
99
|
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
|
57
100
|
payload = {"chat_id": chat_id, "text": message}
|
@@ -59,4 +102,3 @@ def send_telegram_message(preset_name: str, message: str) -> None:
|
|
59
102
|
# Send the message
|
60
103
|
response = requests.post(url, json=payload)
|
61
104
|
response.raise_for_status()
|
62
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: rgwfuncs
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.20
|
4
4
|
Summary: A functional programming paradigm for mathematical modelling and data science
|
5
5
|
Home-page: https://github.com/ryangerardwilson/rgwfunc
|
6
6
|
Author: Ryan Gerard Wilson
|
@@ -28,7 +28,7 @@ Requires-Dist: google-api-python-client
|
|
28
28
|
|
29
29
|
***By Ryan Gerard Wilson (https://ryangerardwilson.com)***
|
30
30
|
|
31
|
-
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `
|
31
|
+
This library is meant to make ML/ Data Science pipelines more readable. It assumes a linux environment, and the existence of a `.rgwfuncsrc` file for certain features (like db querying, sending data to slack, etc.)
|
32
32
|
|
33
33
|
--------------------------------------------------------------------------------
|
34
34
|
|
@@ -135,11 +135,48 @@ To display all docstrings, use:
|
|
135
135
|
|
136
136
|
--------------------------------------------------------------------------------
|
137
137
|
|
138
|
-
##
|
138
|
+
## String Based Functions
|
139
|
+
|
140
|
+
### 1. str_docs
|
141
|
+
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
142
|
+
|
143
|
+
• Parameters:
|
144
|
+
- `method_type_filter` (str): Optional, comma-separated to select docstring types, or '*' for all.
|
145
|
+
|
146
|
+
• Example:
|
147
|
+
|
148
|
+
import rgwfuncs
|
149
|
+
rgwfuncs.str_docs(method_type_filter='numeric_clean,limit_dataframe')
|
150
|
+
|
151
|
+
--------------------------------------------------------------------------------
|
152
|
+
|
153
|
+
### 2. send_telegram_message
|
154
|
+
|
155
|
+
Send a message to a Telegram chat using a specified preset from your configuration file.
|
156
|
+
|
157
|
+
• Parameters:
|
158
|
+
- `preset_name` (str): The name of the preset to use for sending the message. This should match a preset in the configuration file.
|
159
|
+
- `message` (str): The message text that you want to send to the Telegram chat.
|
160
|
+
|
161
|
+
• Raises:
|
162
|
+
- `RuntimeError`: If the preset is not found in the configuration file or if necessary details (bot token or chat ID) are missing.
|
163
|
+
|
164
|
+
• Example:
|
165
|
+
|
166
|
+
from rgwfuncs import send_telegram_message
|
167
|
+
|
168
|
+
preset_name = "daily_updates"
|
169
|
+
message = "Here is your daily update!"
|
170
|
+
|
171
|
+
send_telegram_message(preset_name, message)
|
172
|
+
|
173
|
+
--------------------------------------------------------------------------------
|
174
|
+
|
175
|
+
## Dataframe Based Functions
|
139
176
|
|
140
177
|
Below is a quick reference of available functions, their purpose, and basic usage examples.
|
141
178
|
|
142
|
-
### 1.
|
179
|
+
### 1. df_docs
|
143
180
|
Print a list of available function names in alphabetical order. If a filter is provided, print the matching docstrings.
|
144
181
|
|
145
182
|
• Parameters:
|
@@ -148,7 +185,7 @@ Print a list of available function names in alphabetical order. If a filter is p
|
|
148
185
|
• Example:
|
149
186
|
|
150
187
|
import rgwfuncs
|
151
|
-
rgwfuncs.
|
188
|
+
rgwfuncs.df_docs(method_type_filter='numeric_clean,limit_dataframe')
|
152
189
|
|
153
190
|
--------------------------------------------------------------------------------
|
154
191
|
|
@@ -1,5 +0,0 @@
|
|
1
|
-
# This file is automatically generated
|
2
|
-
# Dynamically importing functions from modules
|
3
|
-
|
4
|
-
from .df_lib import append_columns, append_percentile_classification_column, append_ranged_classification_column, append_ranged_date_classification_column, append_rows, append_xgb_labels, append_xgb_logistic_regression_predictions, append_xgb_regression_predictions, bag_union_join, bottom_n_unique_values, cascade_sort, delete_rows, docs, drop_duplicates, drop_duplicates_retain_first, drop_duplicates_retain_last, filter_dataframe, filter_indian_mobiles, first_n_rows, from_raw_data, insert_dataframe_in_sqlite_database, last_n_rows, left_join, limit_dataframe, load_data_from_path, load_data_from_query, load_data_from_sqlite_path, mask_against_dataframe, mask_against_dataframe_converse, numeric_clean, order_columns, print_correlation, print_dataframe, print_memory_usage, print_n_frequency_cascading, print_n_frequency_linear, rename_columns, retain_columns, right_join, send_data_to_email, send_data_to_slack, send_dataframe_via_telegram, sync_dataframe_to_sqlite_database, top_n_unique_values, union_join, update_rows
|
5
|
-
from .str_lib import send_telegram_message
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|