rgwfuncs 0.0.18__py3-none-any.whl → 0.0.20__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is automatically generated
2
2
  # Dynamically importing functions from modules
3
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
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
rgwfuncs/df_lib.py CHANGED
@@ -29,7 +29,7 @@ import warnings
29
29
  warnings.filterwarnings("ignore", category=FutureWarning)
30
30
 
31
31
 
32
- def docs(method_type_filter: Optional[str] = None) -> None:
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: Comma-separated column names to analyze.
1688
- order_by: Order of frequency: ACS, DESC, FREQ_ASC, FREQ_DESC.
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.
rgwfuncs/str_lib.py CHANGED
@@ -1,7 +1,50 @@
1
1
  import os
2
2
  import json
3
3
  import requests
4
- from typing import Tuple
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.18
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 `rgwml.config` file for certain features (like db querying, sending data to slack, etc.)
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
- ## Function References and Syntax Examples
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. docs
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.docs(method_type_filter='numeric_clean,limit_dataframe')
188
+ rgwfuncs.df_docs(method_type_filter='numeric_clean,limit_dataframe')
152
189
 
153
190
  --------------------------------------------------------------------------------
154
191
 
@@ -0,0 +1,9 @@
1
+ rgwfuncs/__init__.py,sha256=2nrp3c5VmVrKh0Ih6zELL8niH9nAHN0XnObqe-EpxlE,1169
2
+ rgwfuncs/df_lib.py,sha256=3iWQ-iqKbgCLJsMc5DdnxrZ3sSEMDNZNyOsU6pJy060,67028
3
+ rgwfuncs/str_lib.py,sha256=I5B0WOGaLUGaedMG7hqiKnIqV7Jc9h1RYlgOiC_-iGY,3678
4
+ rgwfuncs-0.0.20.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
5
+ rgwfuncs-0.0.20.dist-info/METADATA,sha256=S1_hL1vNpRPV1uc9RIFatPKoR-e3LhZRysNKCjIM_T0,34680
6
+ rgwfuncs-0.0.20.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
+ rgwfuncs-0.0.20.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
8
+ rgwfuncs-0.0.20.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
9
+ rgwfuncs-0.0.20.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- rgwfuncs/__init__.py,sha256=XqJ8TJuc4HkQq3T5Gzjf3KTBsdJtyi2NKXBgbPuDn0Y,1156
2
- rgwfuncs/df_lib.py,sha256=rY1yVvY04uqR174JwYBFiRnujekr9mbe258wmu9OeeY,67148
3
- rgwfuncs/str_lib.py,sha256=6v9AXZ5wWsWVEcvcIz0B1rTmsvYaD-v53r2sYPcV4pU,2109
4
- rgwfuncs-0.0.18.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
5
- rgwfuncs-0.0.18.dist-info/METADATA,sha256=GfMK-J1vH4CG_fQqQAWwAvDE6JcSqNrKuNKvfOUKV_E,33442
6
- rgwfuncs-0.0.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
- rgwfuncs-0.0.18.dist-info/entry_points.txt,sha256=j-c5IOPIQ0252EaOV6j6STio56sbXl2C4ym_fQ0lXx0,43
8
- rgwfuncs-0.0.18.dist-info/top_level.txt,sha256=aGuVIzWsKiV1f2gCb6mynx0zx5ma0B1EwPGFKVEMTi4,9
9
- rgwfuncs-0.0.18.dist-info/RECORD,,