staran 0.1.3__py3-none-any.whl → 0.2.0__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.
- staran/__init__.py +49 -3
- staran-0.2.0.dist-info/METADATA +24 -0
- staran-0.2.0.dist-info/RECORD +8 -0
- staran-0.1.3.dist-info/METADATA +0 -140
- staran-0.1.3.dist-info/RECORD +0 -8
- {staran-0.1.3.dist-info → staran-0.2.0.dist-info}/WHEEL +0 -0
- {staran-0.1.3.dist-info → staran-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {staran-0.1.3.dist-info → staran-0.2.0.dist-info}/top_level.txt +0 -0
staran/__init__.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Staran - 简化的Python工具库
|
6
6
|
=========================
|
7
7
|
|
8
|
-
基于Python
|
8
|
+
基于Python标准库的轻量级实用工具集,提供日期处理、SQL生成等常用功能。
|
9
9
|
|
10
10
|
主要特性:
|
11
11
|
- 零依赖:仅基于Python标准库
|
@@ -13,10 +13,15 @@ Staran - 简化的Python工具库
|
|
13
13
|
- 直观API:符合Python习惯的设计
|
14
14
|
- 类型安全:完整的参数验证
|
15
15
|
|
16
|
+
工具模块:
|
17
|
+
---------
|
18
|
+
1. Date工具 - 智能日期处理
|
19
|
+
2. SQL工具 - 数据分析SQL生成
|
20
|
+
|
16
21
|
快速开始:
|
17
22
|
---------
|
18
23
|
|
19
|
-
|
24
|
+
Date工具基本用法::
|
20
25
|
|
21
26
|
from staran import Date
|
22
27
|
|
@@ -28,6 +33,23 @@ Staran - 简化的Python工具库
|
|
28
33
|
# 格式保持
|
29
34
|
new_date = date1.add_months(2) # 输出: 202506 (保持原格式)
|
30
35
|
|
36
|
+
SQL工具基本用法::
|
37
|
+
|
38
|
+
from staran import TableSchema, FeatureGenerator
|
39
|
+
|
40
|
+
# 定义表结构
|
41
|
+
schema = TableSchema('user_behavior')
|
42
|
+
schema.add_primary_key('user_id', 'string')
|
43
|
+
schema.add_date_field('date', 'date')
|
44
|
+
schema.add_field('amount', 'decimal', aggregatable=True)
|
45
|
+
schema.add_field('status', 'string')
|
46
|
+
schema.set_monthly_unique(True)
|
47
|
+
|
48
|
+
# 生成特征SQL
|
49
|
+
generator = FeatureGenerator(schema)
|
50
|
+
sql = generator.generate_spark_sql()
|
51
|
+
print(sql)
|
52
|
+
|
31
53
|
多种输出格式::
|
32
54
|
|
33
55
|
date = Date('202504')
|
@@ -37,6 +59,18 @@ Staran - 简化的Python工具库
|
|
37
59
|
print(date.format_chinese()) # 2025年04月01日
|
38
60
|
print(date.format_compact()) # 20250401
|
39
61
|
|
62
|
+
SQL特征生成::
|
63
|
+
|
64
|
+
# 配置特征生成
|
65
|
+
from staran.sql import FeatureConfig
|
66
|
+
|
67
|
+
config = FeatureConfig()
|
68
|
+
config.set_aggregation_types(['sum', 'avg', 'max'])
|
69
|
+
config.set_mom_months([1, 3]) # 1个月、3个月环比
|
70
|
+
|
71
|
+
generator = FeatureGenerator(schema, config)
|
72
|
+
generator.print_feature_summary()
|
73
|
+
|
40
74
|
日期运算::
|
41
75
|
|
42
76
|
date = Date(2025, 4, 15)
|
@@ -73,6 +107,7 @@ Staran - 简化的Python工具库
|
|
73
107
|
|
74
108
|
核心功能:
|
75
109
|
---------
|
110
|
+
Date工具:
|
76
111
|
- Date: 智能日期类,支持格式记忆和多种输出
|
77
112
|
- 日期运算:add_days(), add_months()
|
78
113
|
- 格式化:多种预设格式方法
|
@@ -80,6 +115,13 @@ Staran - 简化的Python工具库
|
|
80
115
|
- 转换:to_timestamp(), to_date(), to_datetime()
|
81
116
|
- 信息:is_leap_year(), weekday(), days_in_month()
|
82
117
|
|
118
|
+
SQL工具:
|
119
|
+
- TableSchema: 表结构定义,支持字段类型和特性配置
|
120
|
+
- FeatureGenerator: 特征生成器,支持聚合、环比、同比特征
|
121
|
+
- SparkSQLGenerator: Spark SQL代码生成
|
122
|
+
- 支持每人每月唯一数据的特征工程
|
123
|
+
- 可配置的聚合类型和时间窗口
|
124
|
+
|
83
125
|
版本信息:
|
84
126
|
---------
|
85
127
|
- 版本: 1.0.0
|
@@ -89,10 +131,14 @@ Staran - 简化的Python工具库
|
|
89
131
|
|
90
132
|
# 导入主要功能
|
91
133
|
from .tools import Date
|
134
|
+
from .sql import TableSchema, FeatureGenerator, SparkSQLGenerator
|
92
135
|
|
93
136
|
# 主要导出
|
94
137
|
__all__ = [
|
95
|
-
'Date'
|
138
|
+
'Date',
|
139
|
+
'TableSchema',
|
140
|
+
'FeatureGenerator',
|
141
|
+
'SparkSQLGenerator'
|
96
142
|
]
|
97
143
|
|
98
144
|
# 包信息
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: staran
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: staran - 高性能Python工具库
|
5
|
+
Home-page: https://github.com/starlxa/staran
|
6
|
+
Author: StarAn
|
7
|
+
Author-email: starlxa@icloud.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Requires-Python: >=3.7
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
Requires-Dist: datetime
|
14
|
+
Requires-Dist: calendar
|
15
|
+
Requires-Dist: re
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: author-email
|
18
|
+
Dynamic: classifier
|
19
|
+
Dynamic: description-content-type
|
20
|
+
Dynamic: home-page
|
21
|
+
Dynamic: license-file
|
22
|
+
Dynamic: requires-dist
|
23
|
+
Dynamic: requires-python
|
24
|
+
Dynamic: summary
|
@@ -0,0 +1,8 @@
|
|
1
|
+
staran/__init__.py,sha256=FdJTZ11EB1R2z70W8FsCSgudpbPE68rMEud19pp8VsU,5045
|
2
|
+
staran/tools/__init__.py,sha256=KtudrYnxKD9HZEL4H-mrWlKrmsI3rYjJrLeC9YDTpG4,1054
|
3
|
+
staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
|
4
|
+
staran-0.2.0.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
|
5
|
+
staran-0.2.0.dist-info/METADATA,sha256=ReWJRHI_LYkUc4YWsBTsX2cqCA3XKyJgtm65jAPLjOI,634
|
6
|
+
staran-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
staran-0.2.0.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
|
8
|
+
staran-0.2.0.dist-info/RECORD,,
|
staran-0.1.3.dist-info/METADATA
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: staran
|
3
|
-
Version: 0.1.3
|
4
|
-
Summary: staran - 高性能Python工具库
|
5
|
-
Home-page: https://github.com/starlxa/staran
|
6
|
-
Author: StarAn
|
7
|
-
Author-email: starlxa@icloud.com
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
10
|
-
Requires-Python: >=3.7
|
11
|
-
Description-Content-Type: text/markdown
|
12
|
-
License-File: LICENSE
|
13
|
-
Requires-Dist: datetime
|
14
|
-
Requires-Dist: calendar
|
15
|
-
Requires-Dist: re
|
16
|
-
Dynamic: author
|
17
|
-
Dynamic: author-email
|
18
|
-
Dynamic: classifier
|
19
|
-
Dynamic: description
|
20
|
-
Dynamic: description-content-type
|
21
|
-
Dynamic: home-page
|
22
|
-
Dynamic: license-file
|
23
|
-
Dynamic: requires-dist
|
24
|
-
Dynamic: requires-python
|
25
|
-
Dynamic: summary
|
26
|
-
|
27
|
-
# Staran - 简化的Python工具库
|
28
|
-
|
29
|
-
## � 轻量级Python实用工具集
|
30
|
-
|
31
|
-
Staran是一个基于Python标准库的实用工具库,提供日期处理等常用功能,无需复杂依赖。
|
32
|
-
|
33
|
-
## 🚀 快速开始
|
34
|
-
|
35
|
-
### 安装
|
36
|
-
```bash
|
37
|
-
pip install staran
|
38
|
-
```
|
39
|
-
|
40
|
-
### 基本使用
|
41
|
-
|
42
|
-
```python
|
43
|
-
from staran import Date
|
44
|
-
|
45
|
-
# 创建日期 - 智能格式记忆
|
46
|
-
date1 = Date('202504') # 输出: 202504 (记住年月格式)
|
47
|
-
date2 = Date('20250415') # 输出: 20250415 (记住完整格式)
|
48
|
-
date3 = Date(2025, 4, 15) # 输出: 2025-04-15
|
49
|
-
|
50
|
-
# 日期运算保持格式
|
51
|
-
new_date = date1.add_months(2) # 输出: 202506 (保持YYYYMM格式)
|
52
|
-
```
|
53
|
-
|
54
|
-
## 📖 主要功能
|
55
|
-
|
56
|
-
### 1. 智能格式记忆
|
57
|
-
Date类会根据输入格式自动设置默认输出格式:
|
58
|
-
|
59
|
-
| 输入方式 | 默认输出 | 说明 |
|
60
|
-
|---------|---------|------|
|
61
|
-
| `Date('202504')` | `202504` | 年月紧凑格式 |
|
62
|
-
| `Date('20250415')` | `20250415` | 完整紧凑格式 |
|
63
|
-
| `Date(2025, 4)` | `2025-04` | 年月格式 |
|
64
|
-
| `Date(2025, 4, 15)` | `2025-04-15` | 完整格式 |
|
65
|
-
|
66
|
-
### 2. 多种输出格式
|
67
|
-
```python
|
68
|
-
date = Date('202504')
|
69
|
-
|
70
|
-
# 默认格式(保持输入风格)
|
71
|
-
print(date) # 202504
|
72
|
-
|
73
|
-
# 常用格式
|
74
|
-
print(date.format_full()) # 2025-04-01
|
75
|
-
print(date.format_chinese()) # 2025年04月01日
|
76
|
-
print(date.format_year_month()) # 2025-04
|
77
|
-
print(date.format_compact()) # 20250401
|
78
|
-
```
|
79
|
-
|
80
|
-
### 3. 日期运算
|
81
|
-
```python
|
82
|
-
date = Date('202504')
|
83
|
-
|
84
|
-
# 运算后保持原格式
|
85
|
-
next_month = date.add_months(1) # 202505
|
86
|
-
tomorrow = date.add_days(1) # 202504 (智能处理)
|
87
|
-
|
88
|
-
# 日期差计算
|
89
|
-
diff = date.difference(Date('202502')) # 天数差
|
90
|
-
```
|
91
|
-
|
92
|
-
### 4. 基本信息
|
93
|
-
```python
|
94
|
-
date = Date(2024, 2, 29)
|
95
|
-
print(date.is_leap_year()) # True
|
96
|
-
print(date.weekday()) # 星期几
|
97
|
-
print(date.days_in_month()) # 当月天数
|
98
|
-
```
|
99
|
-
|
100
|
-
## 🎯 设计特色
|
101
|
-
|
102
|
-
- **格式智能** - 自动记忆输入格式,保持输出一致性
|
103
|
-
- **零依赖** - 仅基于Python标准库
|
104
|
-
- **直观API** - 符合Python习惯的设计
|
105
|
-
- **类型安全** - 完整的参数验证和错误处理
|
106
|
-
|
107
|
-
## 📁 项目结构
|
108
|
-
|
109
|
-
```
|
110
|
-
staran/
|
111
|
-
├── __init__.py # 主包入口,包含使用示例
|
112
|
-
├── tools/
|
113
|
-
│ ├── __init__.py # 工具模块
|
114
|
-
│ └── date.py # Date类实现
|
115
|
-
├── setup.py # 安装配置
|
116
|
-
└── README.md # 本文档
|
117
|
-
```
|
118
|
-
|
119
|
-
## 🧪 快速测试
|
120
|
-
|
121
|
-
```python
|
122
|
-
from staran import Date
|
123
|
-
|
124
|
-
# 测试格式记忆
|
125
|
-
date = Date('202504')
|
126
|
-
print(f"原始: {date}") # 202504
|
127
|
-
print(f"加2月: {date.add_months(2)}") # 202506
|
128
|
-
|
129
|
-
# 测试多格式输出
|
130
|
-
print(f"中文: {date.format_chinese()}") # 2025年04月01日
|
131
|
-
print(f"完整: {date.format_full()}") # 2025-04-01
|
132
|
-
```
|
133
|
-
|
134
|
-
## 📄 许可证
|
135
|
-
|
136
|
-
MIT License
|
137
|
-
|
138
|
-
---
|
139
|
-
|
140
|
-
**Staran** - 让Python工具使用更简单 🌟
|
staran-0.1.3.dist-info/RECORD
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
staran/__init__.py,sha256=SzcxcJGSnmBbA9OWuwey1BXbz49zpsOOj3Qunodps9w,3657
|
2
|
-
staran/tools/__init__.py,sha256=KtudrYnxKD9HZEL4H-mrWlKrmsI3rYjJrLeC9YDTpG4,1054
|
3
|
-
staran/tools/date.py,sha256=-QyEMWVx6czMuOIwcV7kR3gBMRVOwb5qevo7GEFSJKE,10488
|
4
|
-
staran-0.1.3.dist-info/licenses/LICENSE,sha256=2EmsBIyDCono4iVXNpv5_px9qt2b7hfPq1WuyGVMNP4,1361
|
5
|
-
staran-0.1.3.dist-info/METADATA,sha256=sNvkxV_9PYfUdkR-F_JZMVoxpq-lXljNJLB2wsxg8B4,3497
|
6
|
-
staran-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
staran-0.1.3.dist-info/top_level.txt,sha256=NOUZtXSh5oSIEjHrC0lQ9WmoKtD010Q00dghWyag-Zs,7
|
8
|
-
staran-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|