feilian 1.3.4__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.
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: feilian
3
+ Version: 1.3.4
4
+ Summary: General data processing tool.
5
+ Author-email: darkpeath <darkpeath@gmail.com>
6
+ Project-URL: Homepage, https://github.com/darkpeath/feilian
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: chardet
9
+ Requires-Dist: pandas
10
+ Provides-Extra: extra
11
+ Requires-Dist: tqdm; extra == "extra"
12
+ Requires-Dist: ijson; extra == "extra"
13
+
14
+ # feilian
15
+
16
+ General data processing tool.
17
+
18
+ ## Features
19
+
20
+ - More default values, less necessary arg.
21
+ - Encapsulation of panda dataframe for simple usage.
22
+
23
+ ## Usage
24
+
25
+ ### Process data with pandas dataframe
26
+
27
+ #### Read a file as dataframe
28
+
29
+ ```python
30
+ import feilian
31
+
32
+ input_file = '' # file can be any csv, json, parquet or xlsx format
33
+ df = feilian.read_dataframe(input_file)
34
+ ```
35
+
36
+ #### Write dataframe to a file
37
+
38
+ ```python
39
+ import feilian
40
+ import pandas as pd
41
+
42
+ df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
43
+ output_file = '' # file can be any csv, json, parquet or xlsx format
44
+ feilian.save_dataframe(output_file, df)
45
+ ```
46
+
47
+ #### Iter a dataframe with a progress bar
48
+
49
+ ```python
50
+ import feilian
51
+ import pandas as pd
52
+
53
+ df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
54
+ feilian.iter_dataframe(data=df, progress_bar="process")
55
+ ```
56
+
57
+ #### Extract sample from a dataframe
58
+
59
+ ```python
60
+ import feilian
61
+ import pandas as pd
62
+
63
+ df = pd.DataFrame(dict(a=[1, 2, 3], b=[4, 5, 6]))
64
+ sample = feilian.extract_dataframe_sample(size=2, shuffle=True)
65
+ ```
66
+
67
+ #### Test text value in dataframe
68
+
69
+ ```python
70
+ import feilian
71
+
72
+ s = ''
73
+
74
+ # test if s is na or empty string
75
+ feilian.is_empty_text(s)
76
+
77
+ # test if s is not na and non-empty string
78
+ feilian.is_nonempty_text(s)
79
+
80
+ # test if s is na or blank string
81
+ feilian.is_blank_text(s)
82
+
83
+ # test if s is not na and non-blank string
84
+ feilian.is_non_blank_text(s)
85
+ ```
86
+
87
+ #### Merge same id rows to one row
88
+
89
+ ```python
90
+ import feilian
91
+ import pandas as pd
92
+
93
+ df = pd.DataFrame([
94
+ {"a": "1", "b": "2", "c": "5"},
95
+ {"a": "2", "b": 6, "c": "8"},
96
+ {"a": "1", "b": 8, "c": "9"},
97
+ ])
98
+
99
+ res = feilian.merge_dataframe_rows(df, col_id="a", join_sep=",")
100
+ ```
101
+
102
+ ### IO for json file
103
+
104
+ #### Read a json file
105
+
106
+ ```python
107
+ import feilian
108
+
109
+ input_file = ''
110
+ data = feilian.read_json(input_file)
111
+ ```
112
+
113
+ #### Write a json file
114
+
115
+ ```python
116
+ import feilian
117
+
118
+ data = [
119
+ {"a": "1", "b": "2", "c": "5"},
120
+ {"a": "2", "b": 6, "c": "8"},
121
+ {"a": "1", "b": 8, "c": "9"},
122
+ ]
123
+ output_file = ''
124
+ feilian.save_dataframe(output_file, data)
125
+ ```
126
+
127
+ ### Datetime format
128
+
129
+ ```python
130
+ import feilian
131
+ import datetime
132
+
133
+ d = datetime.datetime.now()
134
+
135
+ # format a date string
136
+ feilian.format_date(d, sep='-')
137
+
138
+ # format a time string
139
+ feilian.format_time(d, fmt='%H:%M:%S')
140
+ ```
141
+
142
+ ### Process dict
143
+
144
+ #### Flatten dict value
145
+
146
+ ```python
147
+ import feilian
148
+
149
+ data = {
150
+ "a": 12,
151
+ "b": ["4", "s"],
152
+ "c": {
153
+ "l": 0,
154
+ "j": {
155
+ "se": "we",
156
+ "t": 5,
157
+ }
158
+ },
159
+ "f": 7,
160
+ "g": {
161
+ "ts": "9w",
162
+ "j2": 8,
163
+ },
164
+ "w": {
165
+ "s": {
166
+ "ge": 89,
167
+ "00": "ej",
168
+ },
169
+ "r": {
170
+ "le": 33,
171
+ "03": "ef",
172
+ }
173
+ },
174
+ "sk": {
175
+ "a": "23",
176
+ "b": {
177
+ "s": 9,
178
+ "g": 0,
179
+ "p": 4,
180
+ },
181
+ "c": {
182
+ "s": 8,
183
+ "t": "w",
184
+ "j": "23",
185
+ }
186
+ },
187
+ }
188
+ res = feilian.flatten_dict(data, frozen={"g", "w.s", "sk."}, exclude="f")
189
+ ```
190
+
191
+ ### Process args
192
+
193
+ ```python
194
+ from feilian import ArgValueParser
195
+
196
+ value = ''
197
+
198
+ # split value
199
+ ArgValueParser.split_strs_to_list(value)
200
+ ArgValueParser.split_strs_to_set(value)
201
+
202
+ # bound value
203
+ ArgValueParser.bound_set_if_singleton(value)
204
+ ArgValueParser.bound_tuple_if_singleton(value)
205
+ ArgValueParser.bound_list_if_singleton(value)
206
+
207
+ # force value type
208
+ ArgValueParser.ensure_set(value)
209
+ ArgValueParser.ensure_list(value)
210
+ ArgValueParser.ensure_tuple(value)
211
+ ```
212
+
@@ -0,0 +1,18 @@
1
+ feilian/__init__.py,sha256=JR16Mf0rQPgA60-AOQ7KeCU7VQ9zWj-d8UTHiQMeqkA,1286
2
+ feilian/_dist_ver.py,sha256=Sa15b0h5dPrBwT68O64sv25FwCwLjEg7GYtgnB6S3mg,148
3
+ feilian/_typing.py,sha256=5wYeuPbTmweCnP8NwC6qNCCbtTf9D62iAsd7Rn7iAX4,119
4
+ feilian/arg.py,sha256=NEhrSEtQdSnJ0fhTAt1ctbJ7Xh19jzfjcmeMCLUz8DI,8319
5
+ feilian/dataframe.py,sha256=SqvegQEq3jEvDcJoPhBtvYNIc9QAQYwKwcvHZK4I09w,12594
6
+ feilian/datetime.py,sha256=-rZjp2IbYCqoV172CKxstx-psexT9Wca8kuMwUH_in8,765
7
+ feilian/excel.py,sha256=jyPrs4uQ0zKlov2tn10MO6d5jWVGJ4zYzrTF3KveiVM,3418
8
+ feilian/io.py,sha256=aYN3QwWcLoRKzhGMNutqdkmxArVcXfeWXzxCB07LcFc,155
9
+ feilian/json.py,sha256=G51fXAxCzAH28hF6XnDpubxD4GfYTQzUmm_aeQle9T0,8298
10
+ feilian/process.py,sha256=Xk7hnO1qhcn9Wuf53psjBLx9AeikkQvEFAJXxrYa6pk,3269
11
+ feilian/string.py,sha256=YnA6Sz-O9ibj6hKiZHzzSVGS0aLlzzfCqDLGABtL18U,372
12
+ feilian/txt.py,sha256=NNHV4hbGYUtdTRyvN4FQQzL6e0v9aixJwEv2i7LYXjA,2220
13
+ feilian/utils.py,sha256=NfjLsjTG0nj4KaGzKud7IYua8NsY4Xt2DjxCsxmt9ds,2650
14
+ feilian/version.py,sha256=oH_DvE7jRCWlCCX9SSadwxwRJXFas_rIisYLBGPYZn4,350
15
+ feilian-1.3.4.dist-info/METADATA,sha256=1F48OrnKnfNzpZiA1VOLFnZblUhLRfNqsuECN3FkYNY,3784
16
+ feilian-1.3.4.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
17
+ feilian-1.3.4.dist-info/top_level.txt,sha256=1Q2-B6KJrcTr7drW_kik35PTVEUJLPP4wVrn0kYKwGw,8
18
+ feilian-1.3.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (79.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ feilian