pandas-plots 0.11.8__py3-none-any.whl → 0.11.10__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.
pandas_plots/hlp.py CHANGED
@@ -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):
pandas_plots/tbl.py CHANGED
@@ -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 not use_plot:
137
- return
138
-
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
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
- 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,
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
- # * 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]
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
- x = [_cut(item) for item in x]
193
-
194
- figsub = px.bar(
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
- # * add trace to fig, only data not layout, only 1 series
203
- fig.add_trace(figsub["data"][0], row=_row, col=_col)
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
- # * set template
206
- fig.update_layout(
207
- template="plotly_dark" if os.getenv("THEME") == "dark" else "plotly"
208
- )
209
- fig.show(renderer)
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.8
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
@@ -0,0 +1,10 @@
1
+ pandas_plots/hlp.py,sha256=Ug3RGok3Bn_FiPjfmd-_gNskSfzfVplQKR1XQFeykHA,11898
2
+ pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
3
+ pandas_plots/pls.py,sha256=BzZge7TnECjCs47MZ7P63_y2WU23P9sLaMl7SKB5h1Q,35043
4
+ pandas_plots/tbl.py,sha256=ZBxPSX1eoomHkV0o4Zb9X3-M1FL8mVo3uRsRhD6qkP4,24205
5
+ pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
6
+ pandas_plots-0.11.10.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
7
+ pandas_plots-0.11.10.dist-info/METADATA,sha256=haQKrp5-b391Iqmrjsm5N0BoQ7rbWLCPTAHZrKXT4Ko,6858
8
+ pandas_plots-0.11.10.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
9
+ pandas_plots-0.11.10.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
10
+ pandas_plots-0.11.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.2.0)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- pandas_plots/hlp.py,sha256=rlNCOHglkDZWNuf7aeNeatXvOXGLxuxd-iWQf5m0We0,11768
2
- pandas_plots/pii.py,sha256=2WKE-W9s285jPdsTqCgt1uxuW4lj1PYCVOYB2fYDNwQ,2195
3
- pandas_plots/pls.py,sha256=BzZge7TnECjCs47MZ7P63_y2WU23P9sLaMl7SKB5h1Q,35043
4
- pandas_plots/tbl.py,sha256=3mGLD11W6-KyD3XEL74F1OceyPGtqluqFvmL4Qv8PZo,23766
5
- pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
6
- pandas_plots-0.11.8.dist-info/LICENSE,sha256=6KQ5KVAAhRaB-JJKpX4cefKvRZRgI7GUPc92_2d31XY,1051
7
- pandas_plots-0.11.8.dist-info/METADATA,sha256=AQJJiyqleomeOT5M3Lk2MaEjsL8I1o6I3wlaUoES7UQ,6819
8
- pandas_plots-0.11.8.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
9
- pandas_plots-0.11.8.dist-info/top_level.txt,sha256=XnaNuIHBqMmCeh_U7nKOYTwFue_SIA0wxuDgdPmnnSk,13
10
- pandas_plots-0.11.8.dist-info/RECORD,,