data-manipulation 0.41__tar.gz → 0.43__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.
- {data_manipulation-0.41/data_manipulation.egg-info → data_manipulation-0.43}/PKG-INFO +2 -1
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/_version.py +3 -3
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/base.py +25 -3
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/boto3_.py +3 -3
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/pandas_.py +24 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/pyspark_.py +5 -1
- {data_manipulation-0.41 → data_manipulation-0.43/data_manipulation.egg-info}/PKG-INFO +2 -1
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation.egg-info/requires.txt +1 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/setup.py +1 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/LICENSE +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/MANIFEST.in +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/README.md +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/__init__.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/beautifulsoup_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/cryptography_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/django_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/flask_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/geopandas_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/kerberos_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/mysql_connector_python_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/openldap_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/prometheus_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/psycopg2_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/psycopg_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/smtplib_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/sqlalchemy_.py +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation.egg-info/SOURCES.txt +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation.egg-info/dependency_links.txt +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation.egg-info/top_level.txt +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/setup.cfg +0 -0
- {data_manipulation-0.41 → data_manipulation-0.43}/versioneer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: data_manipulation
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.43
|
|
4
4
|
Summary: Powerful data manipulation
|
|
5
5
|
Home-page: https://github.com/shawnngtq/data-manipulation
|
|
6
6
|
Author: Shawn Ng
|
|
@@ -32,6 +32,7 @@ Requires-Dist: pandas
|
|
|
32
32
|
Requires-Dist: psycopg
|
|
33
33
|
Requires-Dist: psycopg2
|
|
34
34
|
Requires-Dist: pyspark
|
|
35
|
+
Requires-Dist: python-dotenv
|
|
35
36
|
Requires-Dist: sqlalchemy
|
|
36
37
|
|
|
37
38
|
|
|
@@ -8,11 +8,11 @@ import json
|
|
|
8
8
|
|
|
9
9
|
version_json = '''
|
|
10
10
|
{
|
|
11
|
-
"date": "2024-
|
|
11
|
+
"date": "2024-09-02T21:39:52+0800",
|
|
12
12
|
"dirty": false,
|
|
13
13
|
"error": null,
|
|
14
|
-
"full-revisionid": "
|
|
15
|
-
"version": "0.
|
|
14
|
+
"full-revisionid": "f2d4c730c96dee3f05eb05b05a1b29a8f92d40a1",
|
|
15
|
+
"version": "0.43"
|
|
16
16
|
}
|
|
17
17
|
''' # END VERSION_JSON
|
|
18
18
|
|
|
@@ -2,10 +2,7 @@ import itertools
|
|
|
2
2
|
import os
|
|
3
3
|
import re
|
|
4
4
|
import subprocess
|
|
5
|
-
from ast import literal_eval
|
|
6
|
-
from distutils.util import strtobool
|
|
7
5
|
from typing import List
|
|
8
|
-
from urllib.parse import urlencode
|
|
9
6
|
|
|
10
7
|
from loguru import logger
|
|
11
8
|
|
|
@@ -121,6 +118,22 @@ def get_country_name_variation() -> dict:
|
|
|
121
118
|
return variations
|
|
122
119
|
|
|
123
120
|
|
|
121
|
+
def get_country_code_variation() -> dict:
|
|
122
|
+
variations = {
|
|
123
|
+
"BA": ["BOSNIA"],
|
|
124
|
+
"BW": ["AFRICA"],
|
|
125
|
+
"CN": ["REPUBLIC OF CHINA"],
|
|
126
|
+
"CZ": ["CZECH REPUBLIC"],
|
|
127
|
+
"KR": ["REPUBLIC OF KOREA"],
|
|
128
|
+
"MK": ["MACEDONIA"],
|
|
129
|
+
"RU": ["RUSSIAN FEDERATION"],
|
|
130
|
+
"SK": ["SLAVONIC", "SLOVAK REPUBLIC"],
|
|
131
|
+
"TR": ["TURKEY", "TURKIYE"],
|
|
132
|
+
"US": ["UNITED STATES"],
|
|
133
|
+
}
|
|
134
|
+
return variations
|
|
135
|
+
|
|
136
|
+
|
|
124
137
|
def list_tuple_without_none(list_tuple: list | tuple) -> list | tuple:
|
|
125
138
|
"""
|
|
126
139
|
Return the given list / tuple without None variation
|
|
@@ -165,6 +178,8 @@ def list_tuple_without_none(list_tuple: list | tuple) -> list | tuple:
|
|
|
165
178
|
|
|
166
179
|
def string_boolean_to_int(boolean_str_rep: str) -> int:
|
|
167
180
|
"""
|
|
181
|
+
DEPRECATED from python 3.12 onwards
|
|
182
|
+
|
|
168
183
|
Return integer from given string boolean. 1 instead of "true"/"True"/"1". Reference from https://docs.python.org/3/distutils/apiref.html#distutils.util.strtobool
|
|
169
184
|
|
|
170
185
|
Parameters
|
|
@@ -189,7 +204,12 @@ def string_boolean_to_int(boolean_str_rep: str) -> int:
|
|
|
189
204
|
-------
|
|
190
205
|
int
|
|
191
206
|
_description_
|
|
207
|
+
|
|
208
|
+
Reference
|
|
209
|
+
---------
|
|
210
|
+
- https://docs.python.org/3.10/library/distutils.html
|
|
192
211
|
"""
|
|
212
|
+
from distutils.util import strtobool
|
|
193
213
|
|
|
194
214
|
int_ = strtobool(string_str_to_str(boolean_str_rep))
|
|
195
215
|
return int_
|
|
@@ -224,6 +244,7 @@ def string_dlt_to_dlt(dlt_str_rep: str) -> dict | list | tuple:
|
|
|
224
244
|
dict | list | tuple
|
|
225
245
|
_description_
|
|
226
246
|
"""
|
|
247
|
+
from ast import literal_eval
|
|
227
248
|
|
|
228
249
|
dlt = literal_eval(dlt_str_rep)
|
|
229
250
|
return dlt
|
|
@@ -383,6 +404,7 @@ def create_encode_url(url: str, query_params: dict = {}) -> str:
|
|
|
383
404
|
str
|
|
384
405
|
encoded url
|
|
385
406
|
"""
|
|
407
|
+
from urllib.parse import urlencode
|
|
386
408
|
|
|
387
409
|
return f"{url}{urlencode(query_params)}"
|
|
388
410
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import os
|
|
2
|
-
from email.mime.application import MIMEApplication
|
|
3
|
-
from email.mime.multipart import MIMEMultipart
|
|
4
|
-
from email.mime.text import MIMEText
|
|
5
2
|
|
|
6
3
|
from loguru import logger
|
|
7
4
|
|
|
@@ -44,6 +41,9 @@ def send_aws_ses_email(
|
|
|
44
41
|
---------
|
|
45
42
|
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ses/client/send_raw_email.html
|
|
46
43
|
"""
|
|
44
|
+
from email.mime.application import MIMEApplication
|
|
45
|
+
from email.mime.multipart import MIMEMultipart
|
|
46
|
+
from email.mime.text import MIMEText
|
|
47
47
|
|
|
48
48
|
from botocore.exceptions import BotoCoreError, ClientError
|
|
49
49
|
|
|
@@ -20,6 +20,30 @@ def config_pandas_display():
|
|
|
20
20
|
pd.set_option("display.expand_frame_repr", True)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
# JUPYTER
|
|
24
|
+
def is_running_in_jupyter():
|
|
25
|
+
"""
|
|
26
|
+
Running in jupyter?
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
bool
|
|
31
|
+
True means running in jupyter env
|
|
32
|
+
"""
|
|
33
|
+
try:
|
|
34
|
+
# Check if the IPython module is available
|
|
35
|
+
from IPython import get_ipython
|
|
36
|
+
|
|
37
|
+
# Check if we are in a notebook environment
|
|
38
|
+
if "IPKernelApp" in get_ipython().config:
|
|
39
|
+
return True
|
|
40
|
+
else:
|
|
41
|
+
return False
|
|
42
|
+
# IPython module not found, not running in Jupyter Notebook
|
|
43
|
+
except ImportError:
|
|
44
|
+
return False
|
|
45
|
+
|
|
46
|
+
|
|
23
47
|
# COLUMN
|
|
24
48
|
def add_type_columns(dataframe):
|
|
25
49
|
"""
|
|
@@ -3,7 +3,6 @@ import multiprocessing
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
5
|
import pyspark
|
|
6
|
-
import pyspark.sql.functions as F
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
# CONFIG
|
|
@@ -135,6 +134,8 @@ def add_dummy_columns(dataframe, columns, value):
|
|
|
135
134
|
-------
|
|
136
135
|
df : pyspark.sql.dataframe.DataFrame
|
|
137
136
|
"""
|
|
137
|
+
import pyspark.sql.functions as F
|
|
138
|
+
|
|
138
139
|
if not isinstance(dataframe, pyspark.sql.dataframe.DataFrame):
|
|
139
140
|
raise TypeError("Argument must be a Pyspark dataframe ...")
|
|
140
141
|
if not isinstance(columns, list):
|
|
@@ -312,6 +313,8 @@ def rename(dataframe, columns):
|
|
|
312
313
|
-------
|
|
313
314
|
df : pyspark.sql.dataframe.DataFrame
|
|
314
315
|
"""
|
|
316
|
+
import pyspark.sql.functions as F
|
|
317
|
+
|
|
315
318
|
if not isinstance(dataframe, pyspark.sql.dataframe.DataFrame):
|
|
316
319
|
raise TypeError("Argument must be a Pyspark dataframe ...")
|
|
317
320
|
if not isinstance(columns, dict):
|
|
@@ -388,6 +391,7 @@ def group_count(dataframe, columns, n=10):
|
|
|
388
391
|
-------
|
|
389
392
|
df : pyspark.sql.dataframe.DataFrame
|
|
390
393
|
"""
|
|
394
|
+
import pyspark.sql.functions as F
|
|
391
395
|
|
|
392
396
|
if not isinstance(dataframe, pyspark.sql.dataframe.DataFrame):
|
|
393
397
|
raise TypeError("Argument must be a Pyspark dataframe ...")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: data_manipulation
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.43
|
|
4
4
|
Summary: Powerful data manipulation
|
|
5
5
|
Home-page: https://github.com/shawnngtq/data-manipulation
|
|
6
6
|
Author: Shawn Ng
|
|
@@ -32,6 +32,7 @@ Requires-Dist: pandas
|
|
|
32
32
|
Requires-Dist: psycopg
|
|
33
33
|
Requires-Dist: psycopg2
|
|
34
34
|
Requires-Dist: pyspark
|
|
35
|
+
Requires-Dist: python-dotenv
|
|
35
36
|
Requires-Dist: sqlalchemy
|
|
36
37
|
|
|
37
38
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation/mysql_connector_python_.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{data_manipulation-0.41 → data_manipulation-0.43}/data_manipulation.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|