onekit 2.0.0__tar.gz → 2.1.1__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.
- {onekit-2.0.0 → onekit-2.1.1}/LICENSE +1 -1
- {onekit-2.0.0 → onekit-2.1.1}/PKG-INFO +18 -4
- {onekit-2.0.0 → onekit-2.1.1}/README.md +7 -1
- {onekit-2.0.0 → onekit-2.1.1}/pyproject.toml +26 -34
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/dekit.py +4 -6
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/mathkit.py +7 -7
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/numpykit.py +6 -5
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/optfunckit.py +15 -14
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/pandaskit.py +12 -12
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/pythonkit.py +87 -48
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/sklearnkit.py +6 -4
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/sparkkit.py +41 -41
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/vizkit.py +20 -18
- {onekit-2.0.0 → onekit-2.1.1}/src/onekit/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: onekit
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
4
4
|
Summary: All-in-One Python Kit.
|
|
5
5
|
License: BSD 3-Clause
|
|
6
6
|
Keywords: onekit
|
|
@@ -9,8 +9,16 @@ Author-email: estripling042@gmail.com
|
|
|
9
9
|
Requires-Python: >=3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Provides-Extra: analytics
|
|
14
|
+
Provides-Extra: base
|
|
15
|
+
Provides-Extra: pyspark
|
|
16
|
+
Requires-Dist: pandas[compression,computation,excel,output-formatting,parquet,performance,plot] (>=2.2.3,<3.0.0) ; extra == "analytics"
|
|
17
|
+
Requires-Dist: pyspark (==3.5.3) ; extra == "pyspark"
|
|
18
|
+
Requires-Dist: pytz (>=2025.2,<2026.0) ; extra == "base"
|
|
19
|
+
Requires-Dist: scikit-learn (>=1.6.1,<2.0.0) ; extra == "analytics"
|
|
20
|
+
Requires-Dist: toolz (>=1.0.0,<2.0.0) ; extra == "base"
|
|
21
|
+
Requires-Dist: tqdm (>=4.67.1,<5.0.0) ; extra == "analytics"
|
|
14
22
|
Description-Content-Type: text/markdown
|
|
15
23
|
|
|
16
24
|
<p align="center">
|
|
@@ -39,10 +47,16 @@ All-in-One Python Kit:
|
|
|
39
47
|
|
|
40
48
|
`onekit` is available on [PyPI](https://pypi.org/project/onekit/) for Python 3.11+:
|
|
41
49
|
|
|
42
|
-
```
|
|
50
|
+
```shell
|
|
43
51
|
pip install onekit
|
|
44
52
|
```
|
|
45
53
|
|
|
54
|
+
With optional dependencies:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
pip install onekit[base,analytics,pyspark]
|
|
58
|
+
```
|
|
59
|
+
|
|
46
60
|
## Disclaimer
|
|
47
61
|
|
|
48
62
|
⚠️ This is a personal project: Use at your own risk!
|
|
@@ -24,10 +24,16 @@ All-in-One Python Kit:
|
|
|
24
24
|
|
|
25
25
|
`onekit` is available on [PyPI](https://pypi.org/project/onekit/) for Python 3.11+:
|
|
26
26
|
|
|
27
|
-
```
|
|
27
|
+
```shell
|
|
28
28
|
pip install onekit
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
With optional dependencies:
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
pip install onekit[base,analytics,pyspark]
|
|
35
|
+
```
|
|
36
|
+
|
|
31
37
|
## Disclaimer
|
|
32
38
|
|
|
33
39
|
⚠️ This is a personal project: Use at your own risk!
|
|
@@ -13,32 +13,40 @@ keywords = ["onekit"]
|
|
|
13
13
|
packages = [
|
|
14
14
|
{ include = "onekit", from = "src" },
|
|
15
15
|
]
|
|
16
|
-
requires-python = ">=3.11"
|
|
17
|
-
dependencies = [
|
|
18
|
-
"toolz (>=1.0.0,<2.0.0)",
|
|
19
|
-
"pytz (>=2025.1,<2026.0)",
|
|
20
|
-
]
|
|
21
16
|
classifiers = [
|
|
22
17
|
"Programming Language :: Python :: 3 :: Only",
|
|
23
18
|
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
24
20
|
]
|
|
21
|
+
requires-python = ">=3.11"
|
|
22
|
+
dependencies = []
|
|
25
23
|
|
|
26
24
|
[tool.poetry]
|
|
27
|
-
version = "2.
|
|
25
|
+
version = "2.1.1"
|
|
28
26
|
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
base = [
|
|
29
|
+
"toolz (>=1.0.0,<2.0.0)",
|
|
30
|
+
"pytz (>=2025.2,<2026.0)",
|
|
31
|
+
]
|
|
32
|
+
analytics = [
|
|
33
|
+
"pandas[compression,computation,excel,output-formatting,parquet,performance,plot] (>=2.2.3,<3.0.0)",
|
|
34
|
+
"scikit-learn (>=1.6.1,<2.0.0)",
|
|
35
|
+
"tqdm (>=4.67.1,<5.0.0)",
|
|
36
|
+
]
|
|
37
|
+
pyspark = ["pyspark (==3.5.3)"]
|
|
36
38
|
|
|
37
|
-
[tool.poetry.group.
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
[tool.poetry.group.dev.dependencies]
|
|
40
|
+
autoflake = "^2.3.1"
|
|
41
|
+
black = { extras = ["jupyter"], version = "^25.1.0" }
|
|
42
|
+
isort = "^6.0.1"
|
|
43
|
+
flake8 = "^7.1.2"
|
|
44
|
+
pre-commit = "^4.2.0"
|
|
45
|
+
pre-commit-hooks = "^5.0.0"
|
|
46
|
+
pytest = "^8.3.5"
|
|
47
|
+
pytest-cov = "^6.0.0"
|
|
40
48
|
pytest-skip-slow = "^0.0.5"
|
|
41
|
-
time-machine = "^2.
|
|
49
|
+
time-machine = "^2.16.0"
|
|
42
50
|
|
|
43
51
|
[tool.poetry.group.docs.dependencies]
|
|
44
52
|
furo = "^2023.9.10"
|
|
@@ -47,27 +55,11 @@ myst-parser = "^2.0.0"
|
|
|
47
55
|
nbsphinx = "^0.9.3"
|
|
48
56
|
sphinx-autoapi = "^3.0.0"
|
|
49
57
|
sphinx-copybutton = "^0.5.2"
|
|
58
|
+
time-machine = "^2.16.0"
|
|
50
59
|
|
|
51
60
|
[tool.poetry.group.packaging.dependencies]
|
|
52
61
|
python-semantic-release = "^8.3.0"
|
|
53
62
|
|
|
54
|
-
[tool.poetry.group.dekit.dependencies]
|
|
55
|
-
numpy = "1.26.4"
|
|
56
|
-
tqdm = "^4.67.1"
|
|
57
|
-
|
|
58
|
-
[tool.poetry.group.pandaskit.dependencies]
|
|
59
|
-
pandas = ">=0.23.2"
|
|
60
|
-
tabulate = "^0.9.0"
|
|
61
|
-
|
|
62
|
-
[tool.poetry.group.sklearnkit.dependencies]
|
|
63
|
-
scikit-learn = ">=1.3"
|
|
64
|
-
|
|
65
|
-
[tool.poetry.group.sparkkit.dependencies]
|
|
66
|
-
pyspark = "3.5.3"
|
|
67
|
-
|
|
68
|
-
[tool.poetry.group.vizkit.dependencies]
|
|
69
|
-
matplotlib = ">=3.7.1"
|
|
70
|
-
|
|
71
63
|
[tool.black]
|
|
72
64
|
line-length = 88
|
|
73
65
|
|
|
@@ -18,8 +18,8 @@ from typing import (
|
|
|
18
18
|
import numpy as np
|
|
19
19
|
import toolz
|
|
20
20
|
|
|
21
|
-
import
|
|
22
|
-
import
|
|
21
|
+
from onekit import numpykit as npk
|
|
22
|
+
from onekit import pythonkit as pk
|
|
23
23
|
|
|
24
24
|
Bounds = list[tuple[float, float]]
|
|
25
25
|
Seed = int | float | random.Random | np.random.RandomState | np.random.Generator | None
|
|
@@ -125,10 +125,8 @@ class KeyFunction:
|
|
|
125
125
|
|
|
126
126
|
@staticmethod
|
|
127
127
|
def neg_inf():
|
|
128
|
-
return (
|
|
129
|
-
|
|
130
|
-
if ind.fx is None or not np.isfinite(ind.fx)
|
|
131
|
-
else ind.fx
|
|
128
|
+
return lambda ind: (
|
|
129
|
+
-float("inf") if ind.fx is None or not np.isfinite(ind.fx) else ind.fx
|
|
132
130
|
)
|
|
133
131
|
|
|
134
132
|
|
|
@@ -59,7 +59,7 @@ def collatz(n: int, /) -> Generator:
|
|
|
59
59
|
Examples
|
|
60
60
|
--------
|
|
61
61
|
>>> import toolz
|
|
62
|
-
>>> import
|
|
62
|
+
>>> from onekit import mathkit as mk
|
|
63
63
|
>>> n = 12
|
|
64
64
|
>>> list(mk.collatz(n))
|
|
65
65
|
[12, 6, 3, 10, 5, 16, 8, 4, 2, 1]
|
|
@@ -125,7 +125,7 @@ def digitscale(x: int | float, /, *, kind: str = "log") -> int | float:
|
|
|
125
125
|
|
|
126
126
|
Examples
|
|
127
127
|
--------
|
|
128
|
-
>>> import
|
|
128
|
+
>>> from onekit import mathkit as mk
|
|
129
129
|
>>> list(map(mk.digitscale, [0.1, 1, 10, 100, 1_000, 10_000, 100_000, 1_000_000]))
|
|
130
130
|
[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]
|
|
131
131
|
|
|
@@ -196,7 +196,7 @@ def fibonacci() -> Generator:
|
|
|
196
196
|
Examples
|
|
197
197
|
--------
|
|
198
198
|
>>> import toolz
|
|
199
|
-
>>> import
|
|
199
|
+
>>> from onekit import mathkit as mk
|
|
200
200
|
>>> list(toolz.take(13, mk.fibonacci()))
|
|
201
201
|
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
|
|
202
202
|
"""
|
|
@@ -216,7 +216,7 @@ def isdivisible(x: int | float, /, n: int) -> bool:
|
|
|
216
216
|
Examples
|
|
217
217
|
--------
|
|
218
218
|
>>> from functools import partial
|
|
219
|
-
>>> import
|
|
219
|
+
>>> from onekit import mathkit as mk
|
|
220
220
|
>>> mk.isdivisible(49, 7)
|
|
221
221
|
True
|
|
222
222
|
|
|
@@ -237,7 +237,7 @@ def iseven(x: int | float, /) -> bool:
|
|
|
237
237
|
|
|
238
238
|
Examples
|
|
239
239
|
--------
|
|
240
|
-
>>> import
|
|
240
|
+
>>> from onekit import mathkit as mk
|
|
241
241
|
>>> mk.iseven(0)
|
|
242
242
|
True
|
|
243
243
|
|
|
@@ -255,7 +255,7 @@ def isodd(x: int | float, /) -> bool:
|
|
|
255
255
|
|
|
256
256
|
Examples
|
|
257
257
|
--------
|
|
258
|
-
>>> import
|
|
258
|
+
>>> from onekit import mathkit as mk
|
|
259
259
|
>>> mk.isodd(0)
|
|
260
260
|
False
|
|
261
261
|
|
|
@@ -282,7 +282,7 @@ def sign(x: int | float, /) -> int:
|
|
|
282
282
|
|
|
283
283
|
Examples
|
|
284
284
|
--------
|
|
285
|
-
>>> import
|
|
285
|
+
>>> from onekit import mathkit as mk
|
|
286
286
|
>>> mk.sign(0)
|
|
287
287
|
0
|
|
288
288
|
|
|
@@ -3,7 +3,7 @@ import random
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import numpy.typing as npt
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
from onekit import mathkit as mk
|
|
7
7
|
|
|
8
8
|
__all__ = (
|
|
9
9
|
"check_random_state",
|
|
@@ -24,7 +24,7 @@ def check_random_state(seed: Seed = None) -> np.random.Generator:
|
|
|
24
24
|
Examples
|
|
25
25
|
--------
|
|
26
26
|
>>> import numpy as np
|
|
27
|
-
>>> import
|
|
27
|
+
>>> from onekit import numpykit as npk
|
|
28
28
|
>>> rng = npk.check_random_state()
|
|
29
29
|
>>> isinstance(rng, np.random.Generator)
|
|
30
30
|
True
|
|
@@ -73,7 +73,7 @@ def check_vector(x: ArrayLike, /, *, n_min: int = 1, n_max: int = np.inf) -> Vec
|
|
|
73
73
|
|
|
74
74
|
Examples
|
|
75
75
|
--------
|
|
76
|
-
>>> import
|
|
76
|
+
>>> from onekit import numpykit as npk
|
|
77
77
|
>>> npk.check_vector([0, 0])
|
|
78
78
|
array([0, 0])
|
|
79
79
|
"""
|
|
@@ -101,7 +101,7 @@ def digitscale(x: ArrayLike, /, *, kind: str = "log") -> np.ndarray:
|
|
|
101
101
|
|
|
102
102
|
Examples
|
|
103
103
|
--------
|
|
104
|
-
>>> import
|
|
104
|
+
>>> from onekit import numpykit as npk
|
|
105
105
|
>>> npk.digitscale([0.1, 1, 10, 100, 1_000, 10_000, 2_000_000])
|
|
106
106
|
array([0. , 1. , 2. , 3. , 4. , 5. , 7.30103])
|
|
107
107
|
|
|
@@ -121,7 +121,8 @@ def stderr(x: ArrayLike, /) -> float:
|
|
|
121
121
|
Examples
|
|
122
122
|
--------
|
|
123
123
|
>>> import numpy as np
|
|
124
|
-
>>> import
|
|
124
|
+
>>> from onekit import numpykit as npk
|
|
125
|
+
>>> np.set_printoptions(legacy="1.21")
|
|
125
126
|
>>> round(npk.stderr([98, 127, 82, 67, 121, np.nan, 119, 92, 110, 113, 107]), 4)
|
|
126
127
|
5.9632
|
|
127
128
|
"""
|
|
@@ -7,6 +7,7 @@ References
|
|
|
7
7
|
.. [wiki] "Test functions for optimization", Wikipedia,
|
|
8
8
|
`<https://en.wikipedia.org/wiki/Test_functions_for_optimization>`_
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
from typing import (
|
|
11
12
|
Callable,
|
|
12
13
|
NamedTuple,
|
|
@@ -16,8 +17,8 @@ import numpy as np
|
|
|
16
17
|
import numpy.typing as npt
|
|
17
18
|
import toolz
|
|
18
19
|
|
|
19
|
-
import
|
|
20
|
-
import
|
|
20
|
+
from onekit import numpykit as npk
|
|
21
|
+
from onekit import vizkit as vk
|
|
21
22
|
|
|
22
23
|
__all__ = (
|
|
23
24
|
"ackley",
|
|
@@ -69,7 +70,7 @@ def ackley(x: Vector, /) -> float:
|
|
|
69
70
|
|
|
70
71
|
Examples
|
|
71
72
|
--------
|
|
72
|
-
>>> import
|
|
73
|
+
>>> from onekit import optfunckit as ofk
|
|
73
74
|
>>> round(ofk.ackley([0, 0]), 4)
|
|
74
75
|
0.0
|
|
75
76
|
|
|
@@ -109,7 +110,7 @@ def beale(x: Vector, /) -> float:
|
|
|
109
110
|
|
|
110
111
|
Examples
|
|
111
112
|
--------
|
|
112
|
-
>>> import
|
|
113
|
+
>>> from onekit import optfunckit as ofk
|
|
113
114
|
>>> ofk.beale([3, 0.5])
|
|
114
115
|
0.0
|
|
115
116
|
|
|
@@ -152,7 +153,7 @@ def bump(x: Vector, /) -> float:
|
|
|
152
153
|
|
|
153
154
|
Examples
|
|
154
155
|
--------
|
|
155
|
-
>>> import
|
|
156
|
+
>>> from onekit import optfunckit as ofk
|
|
156
157
|
>>> round(ofk.bump([0, 0]), 4)
|
|
157
158
|
-0.3679
|
|
158
159
|
|
|
@@ -172,7 +173,7 @@ def fetch_minima(func: Callable, /, n: int) -> list[Minimum] | None:
|
|
|
172
173
|
|
|
173
174
|
Examples
|
|
174
175
|
--------
|
|
175
|
-
>>> import
|
|
176
|
+
>>> from onekit import optfunckit as ofk
|
|
176
177
|
>>> sphere_minima_n5 = ofk.fetch_minima(ofk.sphere, 5)
|
|
177
178
|
>>> sphere_minima_n5
|
|
178
179
|
[Minimum(x=array([0, 0, 0, 0, 0]), fx=0)]
|
|
@@ -317,13 +318,13 @@ def negate(fx: float) -> float:
|
|
|
317
318
|
|
|
318
319
|
Examples
|
|
319
320
|
--------
|
|
320
|
-
>>> import
|
|
321
|
+
>>> from onekit import optfunckit as ofk
|
|
321
322
|
>>> ofk.negate(1.0)
|
|
322
323
|
-1.0
|
|
323
324
|
|
|
324
325
|
>>> # transform into a maximization problem
|
|
325
326
|
>>> import toolz
|
|
326
|
-
>>> import
|
|
327
|
+
>>> from onekit import optfunckit as ofk
|
|
327
328
|
>>> problem = toolz.compose_left(ofk.ackley, ofk.negate)
|
|
328
329
|
>>> round(problem([0, 0]), 4)
|
|
329
330
|
0.0
|
|
@@ -362,7 +363,7 @@ def peaks(x: Vector, /) -> float:
|
|
|
362
363
|
|
|
363
364
|
Examples
|
|
364
365
|
--------
|
|
365
|
-
>>> import
|
|
366
|
+
>>> from onekit import optfunckit as ofk
|
|
366
367
|
>>> round(ofk.peaks([0, 0]), 4)
|
|
367
368
|
0.981
|
|
368
369
|
"""
|
|
@@ -387,7 +388,7 @@ def rastrigin(x: Vector, /) -> float:
|
|
|
387
388
|
|
|
388
389
|
Examples
|
|
389
390
|
--------
|
|
390
|
-
>>> import
|
|
391
|
+
>>> from onekit import optfunckit as ofk
|
|
391
392
|
>>> round(ofk.rastrigin([0, 0]), 4)
|
|
392
393
|
0.0
|
|
393
394
|
|
|
@@ -420,7 +421,7 @@ def rosenbrock(x: Vector, /) -> float:
|
|
|
420
421
|
|
|
421
422
|
Examples
|
|
422
423
|
--------
|
|
423
|
-
>>> import
|
|
424
|
+
>>> from onekit import optfunckit as ofk
|
|
424
425
|
>>> round(ofk.rosenbrock([0, 0]), 4)
|
|
425
426
|
1.0
|
|
426
427
|
|
|
@@ -459,7 +460,7 @@ def schwefel(x: Vector, /) -> float:
|
|
|
459
460
|
|
|
460
461
|
Examples
|
|
461
462
|
--------
|
|
462
|
-
>>> import
|
|
463
|
+
>>> from onekit import optfunckit as ofk
|
|
463
464
|
>>> round(ofk.schwefel([420.9687]), 4)
|
|
464
465
|
0.0
|
|
465
466
|
|
|
@@ -499,7 +500,7 @@ def sinc(x: Vector, /) -> float:
|
|
|
499
500
|
|
|
500
501
|
Examples
|
|
501
502
|
--------
|
|
502
|
-
>>> import
|
|
503
|
+
>>> from onekit import optfunckit as ofk
|
|
503
504
|
>>> ofk.sinc([0])
|
|
504
505
|
-1.0
|
|
505
506
|
|
|
@@ -522,7 +523,7 @@ def sphere(x: Vector, /) -> float:
|
|
|
522
523
|
|
|
523
524
|
Examples
|
|
524
525
|
--------
|
|
525
|
-
>>> import
|
|
526
|
+
>>> from onekit import optfunckit as ofk
|
|
526
527
|
>>> ofk.sphere([0, 0])
|
|
527
528
|
0.0
|
|
528
529
|
|
|
@@ -10,7 +10,7 @@ import toolz
|
|
|
10
10
|
from pandas import DataFrame as PandasDF
|
|
11
11
|
from tabulate import tabulate
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
from onekit import pythonkit as pk
|
|
14
14
|
|
|
15
15
|
__all__ = (
|
|
16
16
|
"cvf",
|
|
@@ -29,7 +29,7 @@ def cvf(*cols: str | Iterable[str]) -> PandasDFPipeFunc:
|
|
|
29
29
|
Examples
|
|
30
30
|
--------
|
|
31
31
|
>>> import pandas as pd
|
|
32
|
-
>>> import
|
|
32
|
+
>>> from onekit import pandaskit as pdk
|
|
33
33
|
>>> df = pd.DataFrame({"x": ["a", "c", "b", "g", "h", "a", "g", "a"]})
|
|
34
34
|
>>> df.pipe(pdk.cvf("x"))
|
|
35
35
|
x count percent cumul_count cumul_percent
|
|
@@ -66,7 +66,7 @@ def cvf(*cols: str | Iterable[str]) -> PandasDFPipeFunc:
|
|
|
66
66
|
|
|
67
67
|
def display(
|
|
68
68
|
df: PandasDF,
|
|
69
|
-
|
|
69
|
+
label: str | None = None,
|
|
70
70
|
na_rep: str | None = "NULL",
|
|
71
71
|
drop_original_index: bool = True,
|
|
72
72
|
with_row_numbers: bool = True,
|
|
@@ -76,7 +76,7 @@ def display(
|
|
|
76
76
|
Examples
|
|
77
77
|
--------
|
|
78
78
|
>>> import pandas as pd
|
|
79
|
-
>>> import
|
|
79
|
+
>>> from onekit import pandaskit as pdk
|
|
80
80
|
>>> df = pd.DataFrame([dict(x=1, y=2), dict(x=3, y=4), dict(x=None, y=6)])
|
|
81
81
|
>>> pdk.display(df)
|
|
82
82
|
+----+------+-----+
|
|
@@ -89,7 +89,7 @@ def display(
|
|
|
89
89
|
| 3 | NULL | 6 |
|
|
90
90
|
+----+------+-----+
|
|
91
91
|
"""
|
|
92
|
-
|
|
92
|
+
with_label = label is not None
|
|
93
93
|
|
|
94
94
|
def print_tabulated_df() -> None:
|
|
95
95
|
tabulated_df = tabulate(
|
|
@@ -100,9 +100,9 @@ def display(
|
|
|
100
100
|
intfmt="_g",
|
|
101
101
|
missingval=na_rep,
|
|
102
102
|
)
|
|
103
|
-
if
|
|
103
|
+
if with_label:
|
|
104
104
|
n = max(map(len, tabulated_df.splitlines()))
|
|
105
|
-
print(pk.headline(
|
|
105
|
+
print(pk.headline(label, n=n, fillchar="="))
|
|
106
106
|
print(tabulated_df)
|
|
107
107
|
|
|
108
108
|
if with_row_numbers:
|
|
@@ -116,9 +116,9 @@ def display(
|
|
|
116
116
|
try:
|
|
117
117
|
from IPython.display import display as notebook_display
|
|
118
118
|
|
|
119
|
-
df_style = df.style.set_caption(
|
|
119
|
+
df_style = df.style.set_caption(label) if with_label else df.style
|
|
120
120
|
table_styles = []
|
|
121
|
-
if
|
|
121
|
+
if with_label:
|
|
122
122
|
table_styles.append(
|
|
123
123
|
dict(
|
|
124
124
|
selector="caption",
|
|
@@ -160,7 +160,7 @@ def join(
|
|
|
160
160
|
Examples
|
|
161
161
|
--------
|
|
162
162
|
>>> import pandas as pd
|
|
163
|
-
>>> import
|
|
163
|
+
>>> from onekit import pandaskit as pdk
|
|
164
164
|
>>> df1 = pd.DataFrame([dict(a=1, b=3), dict(a=2, b=4)])
|
|
165
165
|
>>> df2 = pd.DataFrame([dict(a=1, c=5), dict(a=2, c=6)])
|
|
166
166
|
>>> df3 = pd.DataFrame([dict(a=1, d=7)])
|
|
@@ -182,7 +182,7 @@ def profile(df: PandasDF, /, *, q: list[int] | None = None) -> PandasDF:
|
|
|
182
182
|
Examples
|
|
183
183
|
--------
|
|
184
184
|
>>> import pandas as pd
|
|
185
|
-
>>> import
|
|
185
|
+
>>> from onekit import pandaskit as pdk
|
|
186
186
|
>>> data = {
|
|
187
187
|
... "a": [True, None, False, False, True, False],
|
|
188
188
|
... "b": [1] * 6,
|
|
@@ -256,7 +256,7 @@ def union(*dataframes: PandasDF | Iterable[PandasDF]) -> PandasDF:
|
|
|
256
256
|
Examples
|
|
257
257
|
--------
|
|
258
258
|
>>> import pandas as pd
|
|
259
|
-
>>> import
|
|
259
|
+
>>> from onekit import pandaskit as pdk
|
|
260
260
|
>>> df1 = pd.DataFrame([dict(x=1, y=2), dict(x=3, y=4)])
|
|
261
261
|
>>> df2 = pd.DataFrame([dict(x=5, y=6), dict(x=7, y=8)])
|
|
262
262
|
>>> df3 = pd.DataFrame([dict(x=0, y=1), dict(x=2, y=3)])
|