pandas-plots 0.11.8__tar.gz → 0.11.10__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.
- {pandas_plots-0.11.8/src/pandas_plots.egg-info → pandas_plots-0.11.10}/PKG-INFO +3 -2
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/README.md +1 -1
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/setup.cfg +2 -1
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots/hlp.py +6 -2
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots/tbl.py +73 -69
- {pandas_plots-0.11.8 → pandas_plots-0.11.10/src/pandas_plots.egg-info}/PKG-INFO +3 -2
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots.egg-info/requires.txt +1 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/LICENSE +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/pyproject.toml +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots/pii.py +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots/pls.py +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots/ven.py +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots.egg-info/SOURCES.txt +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots.egg-info/dependency_links.txt +0 -0
- {pandas_plots-0.11.8 → pandas_plots-0.11.10}/src/pandas_plots.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pandas-plots
|
3
|
-
Version: 0.11.
|
3
|
+
Version: 0.11.10
|
4
4
|
Summary: A collection of helper for table handling and vizualization
|
5
5
|
Home-page: https://github.com/smeisegeier/pandas-plots
|
6
6
|
Author: smeisegeier
|
@@ -27,6 +27,7 @@ Requires-Dist: seaborn>=0.13.2
|
|
27
27
|
Requires-Dist: Jinja2>=3.1.4
|
28
28
|
Requires-Dist: requests>=2.32.0
|
29
29
|
Requires-Dist: numpy<2.0.0
|
30
|
+
Requires-Dist: missingno>=0.5.2
|
30
31
|
|
31
32
|
# pandas-plots
|
32
33
|
|
@@ -43,7 +44,7 @@ pip install pandas-plots -U
|
|
43
44
|
include in python
|
44
45
|
|
45
46
|
```python
|
46
|
-
from pandas_plots import tbl, pls, ven, hlp
|
47
|
+
from pandas_plots import tbl, pls, ven, hlp, pii
|
47
48
|
```
|
48
49
|
|
49
50
|
## example
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[metadata]
|
2
2
|
name = pandas-plots
|
3
|
-
version = 0.11.
|
3
|
+
version = 0.11.10
|
4
4
|
author = smeisegeier
|
5
5
|
author_email = dexterDSDo@googlemail.com
|
6
6
|
description = A collection of helper for table handling and vizualization
|
@@ -33,6 +33,7 @@ install_requires =
|
|
33
33
|
Jinja2 >= 3.1.4
|
34
34
|
requests >= 2.32.0
|
35
35
|
numpy < 2.0.0
|
36
|
+
missingno >= 0.5.2
|
36
37
|
|
37
38
|
[egg_info]
|
38
39
|
tag_build =
|
@@ -271,7 +271,7 @@ def add_datetime_columns(df: pd.DataFrame, date_column: str = None) -> pd.DataFr
|
|
271
271
|
|
272
272
|
|
273
273
|
def show_package_version(
|
274
|
-
packages: list[str] =
|
274
|
+
packages: list[str] = None,
|
275
275
|
sep: str = " | ",
|
276
276
|
include_demo_packages: bool = True,
|
277
277
|
) -> None:
|
@@ -286,6 +286,10 @@ def show_package_version(
|
|
286
286
|
Returns:
|
287
287
|
None
|
288
288
|
"""
|
289
|
+
# ! avoid empty list in signature, it will NOT be empty in runtime
|
290
|
+
if packages is None:
|
291
|
+
packages = []
|
292
|
+
|
289
293
|
if not isinstance(packages, List):
|
290
294
|
print(f"❌ A list of str must be provided")
|
291
295
|
return
|
@@ -307,7 +311,7 @@ def show_package_version(
|
|
307
311
|
items.append(f"📦 {item}: {version}")
|
308
312
|
except md.PackageNotFoundError:
|
309
313
|
items.append(f"❌ {item}: Not found")
|
310
|
-
print(sep.join(items))
|
314
|
+
print('\n',sep.join(items))
|
311
315
|
return
|
312
316
|
|
313
317
|
class OperatingSystem(Enum):
|
@@ -34,6 +34,7 @@ def describe_df(
|
|
34
34
|
caption: str,
|
35
35
|
use_plot: bool = True,
|
36
36
|
use_columns: bool = True,
|
37
|
+
use_missing: bool = True,
|
37
38
|
renderer: Literal["png", "svg", None] = "png",
|
38
39
|
fig_cols: int = 3,
|
39
40
|
fig_offset: int = None,
|
@@ -51,6 +52,7 @@ def describe_df(
|
|
51
52
|
caption (str): caption to describe dataframe
|
52
53
|
use_plot (bool): display plot?
|
53
54
|
use_columns (bool): display columns values?
|
55
|
+
use_missing (bool): display missing values? (looks better on light theme)
|
54
56
|
renderer (Literal["png", "svg", None]): renderer for plot
|
55
57
|
fig_cols (int): number of columns in plot
|
56
58
|
fig_offset (int): offset for plots as iloc Argument. None = no offset, -1 = omit last plot
|
@@ -133,80 +135,82 @@ def describe_df(
|
|
133
135
|
display(df[:3])
|
134
136
|
|
135
137
|
# ! *** PLOTS ***
|
136
|
-
if
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
138
|
+
if use_plot:
|
139
|
+
# * reduce column names len if selected
|
140
|
+
if top_n_chars_in_columns > 0:
|
141
|
+
# * minumum 10 chars, or display is cluttered
|
142
|
+
top_n_chars_in_columns = (
|
143
|
+
10 if top_n_chars_in_columns < 10 else top_n_chars_in_columns
|
144
|
+
)
|
145
|
+
col_list = []
|
146
|
+
for i, col in enumerate(df.columns):
|
147
|
+
col_list.append(col[:top_n_chars_in_columns] + "_" + str(i).zfill(3))
|
148
|
+
df.columns = col_list
|
149
|
+
|
150
|
+
# * respect fig_offset to exclude unwanted plots from maintanance columns
|
151
|
+
cols = df.iloc[:, :fig_offset].columns
|
152
|
+
cols_num = df.select_dtypes(np.number).columns.tolist()
|
153
|
+
# cols_str = list(set(df.columns) - set(cols_num))
|
154
|
+
|
155
|
+
# * set constant column count, calc rows
|
156
|
+
fig_rows = math.ceil(len(cols) / fig_cols)
|
157
|
+
|
158
|
+
fig = make_subplots(
|
159
|
+
rows=fig_rows,
|
160
|
+
cols=fig_cols,
|
161
|
+
shared_xaxes=False,
|
162
|
+
shared_yaxes=False,
|
163
|
+
subplot_titles=cols,
|
144
164
|
)
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
fig_rows = math.ceil(len(cols) / fig_cols)
|
157
|
-
|
158
|
-
fig = make_subplots(
|
159
|
-
rows=fig_rows,
|
160
|
-
cols=fig_cols,
|
161
|
-
shared_xaxes=False,
|
162
|
-
shared_yaxes=False,
|
163
|
-
subplot_titles=cols,
|
164
|
-
)
|
165
|
-
# * layout settings
|
166
|
-
fig.layout.height = fig_rowheight * fig_rows
|
167
|
-
fig.layout.width = 400 * fig_cols
|
168
|
-
|
169
|
-
# * construct subplots
|
170
|
-
for i, col in enumerate(cols):
|
171
|
-
# * get unique values as sorted list
|
172
|
-
if sort_mode == "value":
|
173
|
-
span = df[col].value_counts().sort_values(ascending=False)
|
174
|
-
else:
|
175
|
-
span = df[col].value_counts().sort_index()
|
165
|
+
# * layout settings
|
166
|
+
fig.layout.height = fig_rowheight * fig_rows
|
167
|
+
fig.layout.width = 400 * fig_cols
|
168
|
+
|
169
|
+
# * construct subplots
|
170
|
+
for i, col in enumerate(cols):
|
171
|
+
# * get unique values as sorted list
|
172
|
+
if sort_mode == "value":
|
173
|
+
span = df[col].value_counts().sort_values(ascending=False)
|
174
|
+
else:
|
175
|
+
span = df[col].value_counts().sort_index()
|
176
176
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
177
|
+
# * check if num col w/ too many values (disabled)
|
178
|
+
if col in cols_num and len(span) > 100 and False:
|
179
|
+
figsub = px.box(df, x=col, points="outliers")
|
180
|
+
else:
|
181
|
+
# * only respect 100 items (fixed value)
|
182
|
+
x = span.iloc[:100].index
|
183
|
+
y = span.iloc[:100].values
|
184
|
+
# * cut long strings
|
185
|
+
if x.dtype == "object" and top_n_chars_in_index > 0:
|
186
|
+
x = x.astype(str).tolist()
|
187
|
+
_cut = lambda s: (
|
188
|
+
s[:top_n_chars_in_index] + ".."
|
189
|
+
if len(s) > top_n_chars_in_index
|
190
|
+
else s[:top_n_chars_in_index]
|
191
|
+
)
|
192
|
+
x = [_cut(item) for item in x]
|
193
|
+
|
194
|
+
figsub = px.bar(
|
195
|
+
x=x,
|
196
|
+
y=y,
|
191
197
|
)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
x=x,
|
196
|
-
y=y,
|
197
|
-
)
|
198
|
-
# * grid position
|
199
|
-
_row = math.floor((i) / fig_cols) + 1
|
200
|
-
_col = i % fig_cols + 1
|
198
|
+
# * grid position
|
199
|
+
_row = math.floor((i) / fig_cols) + 1
|
200
|
+
_col = i % fig_cols + 1
|
201
201
|
|
202
|
-
|
203
|
-
|
202
|
+
# * add trace to fig, only data not layout, only 1 series
|
203
|
+
fig.add_trace(figsub["data"][0], row=_row, col=_col)
|
204
204
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
205
|
+
# * set template
|
206
|
+
fig.update_layout(
|
207
|
+
template="plotly_dark" if os.getenv("THEME") == "dark" else "plotly"
|
208
|
+
)
|
209
|
+
fig.show(renderer)
|
210
|
+
|
211
|
+
if use_missing:
|
212
|
+
import missingno as msno
|
213
|
+
msno.matrix(df, figsize=(12, 5))
|
210
214
|
|
211
215
|
|
212
216
|
def pivot_df(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pandas-plots
|
3
|
-
Version: 0.11.
|
3
|
+
Version: 0.11.10
|
4
4
|
Summary: A collection of helper for table handling and vizualization
|
5
5
|
Home-page: https://github.com/smeisegeier/pandas-plots
|
6
6
|
Author: smeisegeier
|
@@ -27,6 +27,7 @@ Requires-Dist: seaborn>=0.13.2
|
|
27
27
|
Requires-Dist: Jinja2>=3.1.4
|
28
28
|
Requires-Dist: requests>=2.32.0
|
29
29
|
Requires-Dist: numpy<2.0.0
|
30
|
+
Requires-Dist: missingno>=0.5.2
|
30
31
|
|
31
32
|
# pandas-plots
|
32
33
|
|
@@ -43,7 +44,7 @@ pip install pandas-plots -U
|
|
43
44
|
include in python
|
44
45
|
|
45
46
|
```python
|
46
|
-
from pandas_plots import tbl, pls, ven, hlp
|
47
|
+
from pandas_plots import tbl, pls, ven, hlp, pii
|
47
48
|
```
|
48
49
|
|
49
50
|
## example
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|