mdbq 3.8.8__tar.gz → 3.8.9__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.
Files changed (41) hide show
  1. {mdbq-3.8.8 → mdbq-3.8.9}/PKG-INFO +1 -1
  2. mdbq-3.8.9/mdbq/__version__.py +1 -0
  3. mdbq-3.8.9/mdbq/other/otk.py +81 -0
  4. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq.egg-info/PKG-INFO +1 -1
  5. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq.egg-info/SOURCES.txt +1 -0
  6. mdbq-3.8.8/mdbq/__version__.py +0 -1
  7. {mdbq-3.8.8 → mdbq-3.8.9}/README.txt +0 -0
  8. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/__init__.py +0 -0
  9. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/aggregation/__init__.py +0 -0
  10. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/aggregation/query_data.py +0 -0
  11. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/bdup/__init__.py +0 -0
  12. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/bdup/bdup.py +0 -0
  13. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/config/__init__.py +0 -0
  14. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/config/config.py +0 -0
  15. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/config/set_support.py +0 -0
  16. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/dataframe/__init__.py +0 -0
  17. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/dataframe/converter.py +0 -0
  18. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/log/__init__.py +0 -0
  19. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/log/mylogger.py +0 -0
  20. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/log/spider_logging.py +0 -0
  21. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/mongo/__init__.py +0 -0
  22. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/mysql/__init__.py +0 -0
  23. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/mysql/mysql.py +0 -0
  24. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/mysql/s_query.py +0 -0
  25. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/mysql/year_month_day.py +0 -0
  26. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/other/__init__.py +0 -0
  27. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/other/download_sku_picture.py +0 -0
  28. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/other/porxy.py +0 -0
  29. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/other/pov_city.py +0 -0
  30. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/other/ua_sj.py +0 -0
  31. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/pbix/__init__.py +0 -0
  32. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/pbix/pbix_refresh.py +0 -0
  33. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/pbix/refresh_all.py +0 -0
  34. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/redis/__init__.py +0 -0
  35. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/redis/getredis.py +0 -0
  36. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/spider/__init__.py +0 -0
  37. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq/spider/aikucun.py +0 -0
  38. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq.egg-info/dependency_links.txt +0 -0
  39. {mdbq-3.8.8 → mdbq-3.8.9}/mdbq.egg-info/top_level.txt +0 -0
  40. {mdbq-3.8.8 → mdbq-3.8.9}/setup.cfg +0 -0
  41. {mdbq-3.8.8 → mdbq-3.8.9}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mdbq
3
- Version: 3.8.8
3
+ Version: 3.8.9
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -0,0 +1 @@
1
+ VERSION = '3.8.9'
@@ -0,0 +1,81 @@
1
+ import re
2
+ import calendar
3
+ import datetime
4
+ from dateutil.relativedelta import relativedelta
5
+ import pandas as pd
6
+ import numpy as np
7
+
8
+
9
+ def first_and_last_day(date):
10
+ """
11
+ 返回指定日期当月的第一天和最后一天
12
+ """
13
+ date = pd.to_datetime(date) # n 月以前的今天
14
+ _, _lastDay = calendar.monthrange(date.year, date.month) # 返回月的第一天的星期和当月总天数
15
+ _firstDay = datetime.date(date.year, date.month, day=1)
16
+ _lastDay = datetime.date(date.year, date.month, day=_lastDay)
17
+ return _firstDay, _lastDay
18
+
19
+
20
+ def get_day_of_month(num: int, fm=None):
21
+ """
22
+ num: 获取n月以前的第一天和最后一天, num=0时, 返回当月第一天和最后一天
23
+ fm: 日期输出格式
24
+ """
25
+ if not fm:
26
+ fm ='%Y%m%d'
27
+ _today = datetime.date.today()
28
+ months_ago = _today - relativedelta(months=num) # n 月以前的今天
29
+ _, _lastDay = calendar.monthrange(months_ago.year, months_ago.month) # 返回月的第一天的星期和当月总天数
30
+ _firstDay = datetime.date(months_ago.year, months_ago.month, day=1).strftime(fm)
31
+ _lastDay = datetime.date(months_ago.year, months_ago.month, day=_lastDay).strftime(fm)
32
+ return _firstDay, _lastDay
33
+
34
+
35
+ def dates_between(start_date, end_date, fm=None) -> list:
36
+ """
37
+ 获取两个日期之间的所有日期, 返回 list
38
+ fm: 日期输出格式
39
+ """
40
+ if not fm:
41
+ fm ='%Y%m%d'
42
+ start_date = pd.to_datetime(start_date)
43
+ end_date = pd.to_datetime(end_date)
44
+ dates = []
45
+ current_date = start_date
46
+ while current_date <= end_date:
47
+ dates.append(current_date.strftime(fm))
48
+ current_date += datetime.timedelta(days=1)
49
+ return dates
50
+
51
+
52
+ def cover_df(df):
53
+ df.replace([np.inf, -np.inf], '0', inplace=True) # 清理一些非法值
54
+ df.replace(to_replace=['\\N', '-', '--', '', 'nan', 'NAN'], value='0', regex=False, inplace=True) # 替换掉特殊字符
55
+ df.replace(to_replace=[','], value='', regex=True, inplace=True)
56
+ df.replace(to_replace=['="'], value='', regex=True, inplace=True) # ="和"不可以放在一起清洗, 因为有: id=86785565
57
+ df.replace(to_replace=['"'], value='', regex=True, inplace=True)
58
+ cols = df.columns.tolist()
59
+ for col in cols:
60
+ df[col] = df[col].apply(
61
+ lambda x: float(float((str(x).rstrip("%"))) / 100) if re.findall(r'^\d+\.?\d*%$', str(x)) else x)
62
+
63
+ new_col = col.lower()
64
+ new_col = re.sub(r'[()\-,,&~^、 ()\"\'“”=·/。》《><!!`]', '_', new_col, re.IGNORECASE)
65
+ new_col = new_col.replace(')', '')
66
+ new_col = re.sub(r'_{2,}', '_', new_col)
67
+ new_col = re.sub(r'_+$', '', new_col)
68
+ df.rename(columns={col: new_col}, inplace=True)
69
+ df.fillna(0, inplace=True)
70
+ return df
71
+
72
+
73
+ def translate_keys(original_dict:dict, translation_dict:dict) -> dict:
74
+ """
75
+ original_dict键名翻译, 若键存在则返回翻译值,否则返回原键
76
+ """
77
+ return {translation_dict.get(k, k): v for k, v in original_dict.items()}
78
+
79
+
80
+ if __name__ == '__main__':
81
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mdbq
3
- Version: 3.8.8
3
+ Version: 3.8.9
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -25,6 +25,7 @@ mdbq/mysql/s_query.py
25
25
  mdbq/mysql/year_month_day.py
26
26
  mdbq/other/__init__.py
27
27
  mdbq/other/download_sku_picture.py
28
+ mdbq/other/otk.py
28
29
  mdbq/other/porxy.py
29
30
  mdbq/other/pov_city.py
30
31
  mdbq/other/ua_sj.py
@@ -1 +0,0 @@
1
- VERSION = '3.8.8'
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
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
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
File without changes
File without changes