pandas-plots 0.15.1__py3-none-any.whl → 0.15.3__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/pls.py CHANGED
@@ -564,13 +564,21 @@ def plot_bars(
564
564
 
565
565
  # * if df, check if valid
566
566
  if isinstance(df_in, pd.DataFrame):
567
- if len(df_in.columns) != 2:
568
- print("❌ df must have exactly 2 columns")
569
- return
570
- elif not (df_in.iloc[:, 0].dtype.kind in ["O", "b"]) or not (
571
- df_in.iloc[:, 1].dtype.kind in ["i", "f"]
572
- ):
573
- print("❌ df must have string and numeric columns (in that order).")
567
+ if len(df_in.columns) == 1:
568
+ if not (df_in.iloc[:, 0].dtype.kind in ["O", "b"]):
569
+ print("❌ df must have 1 column of object or bool type.")
570
+ return
571
+ else:
572
+ df_in = df_in.value_counts(dropna=dropna).to_frame().reset_index()
573
+ use_ci = False
574
+ elif len(df_in.columns) == 2:
575
+ if not (df_in.iloc[:, 0].dtype.kind in ["O", "b"]) or not (
576
+ df_in.iloc[:, 1].dtype.kind in ["i", "f"]
577
+ ):
578
+ print("❌ df must have string and numeric columns (in that order).")
579
+ return
580
+ else:
581
+ print("❌ df must have exactly 1 or 2 columns")
574
582
  return
575
583
  else:
576
584
  print("❌ input must be series or dataframe.")
@@ -1194,6 +1202,10 @@ def plot_boxes(
1194
1202
  xlvl1 = -50
1195
1203
  xlvl2 = 0
1196
1204
  xlvl3 = 50
1205
+
1206
+ # * type of col0 must be str, not object. otherwise px.box will fail since sorting will fail
1207
+ if pd.api.types.is_object_dtype(df.iloc[:, 0]):
1208
+ df.iloc[:, 0] = df.iloc[:, 0].astype(str)
1197
1209
 
1198
1210
  # * unique items
1199
1211
  # Sort the unique items alphabetically
pandas_plots/tbl.py CHANGED
@@ -75,6 +75,7 @@ def describe_df(
75
75
  top_n_uniques: int = 5,
76
76
  top_n_chars_in_index: int = 0,
77
77
  top_n_chars_in_columns: int = 0,
78
+ missing_figsize: tuple[int, int] = (26, 6),
78
79
  ):
79
80
  """
80
81
  This function takes a pandas DataFrame and a caption as input parameters and prints out the caption as a styled header, followed by the shape of the DataFrame and the list of column names. For each column, it prints out the column name, the number of unique values, and the column data type. If the column is a numeric column with more than 100 unique values, it also prints out the minimum, mean, maximum, and sum values. Otherwise, it prints out the first 100 unique values of the column.
@@ -94,6 +95,7 @@ def describe_df(
94
95
  top_n_uniques (int): number of uniques to display
95
96
  top_n_chars_in_index (int): number of characters to display on plot axis
96
97
  top_n_chars_in_columns (int): number of characters to display on plot axis. If set, minimum is 10.
98
+ missing_figsize (tuple[int, int]): figsize for missing plot (default (26, 6)
97
99
 
98
100
  usage:
99
101
  describe_df(
@@ -252,7 +254,7 @@ def describe_df(
252
254
 
253
255
  if use_missing:
254
256
  import missingno as msno
255
- msno.matrix(df_, figsize=(12, 5))
257
+ msno.matrix(df_, figsize=missing_figsize)
256
258
 
257
259
 
258
260
  def pivot_df(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pandas-plots
3
- Version: 0.15.1
3
+ Version: 0.15.3
4
4
  Summary: A collection of helper for table handling and visualization
5
5
  Project-URL: Homepage, https://github.com/smeisegeier/pandas-plots
6
6
  Project-URL: Repository, https://github.com/smeisegeier/pandas-plots
@@ -13,10 +13,10 @@ Classifier: Intended Audience :: Science/Research
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Topic :: Scientific/Engineering
18
18
  Requires-Python: >=3.10
19
- Requires-Dist: connection-helper>=0.11.2
19
+ Requires-Dist: connection-helper>=0.12
20
20
  Requires-Dist: dataframe-image>=0.2.6
21
21
  Requires-Dist: duckdb>=1.3.0
22
22
  Requires-Dist: jinja2>=3.1.4
@@ -41,7 +41,9 @@ Description-Content-Type: text/markdown
41
41
  install / update package
42
42
 
43
43
  ```bash
44
- pip install pandas-plots -U
44
+ uv add -U pandas-plots
45
+ # if no uv is available:
46
+ # pip install pandas-plots -U
45
47
  ```
46
48
 
47
49
  include in python
@@ -79,7 +81,7 @@ tbl.show_num_df(
79
81
  `pandas-plots` is a package to help you examine and visualize data that are organized in a pandas DataFrame. It provides a high level api to pandas / plotly with some selected functions and predefined options:
80
82
 
81
83
  - `tbl` utilities for table descriptions
82
- - 🌟`show_num_df()` displays a table as styled version with additional information
84
+ - `show_num_df()` displays a table as styled version with additional information
83
85
  - `describe_df()` an alternative version of pandas `describe()` function
84
86
  - `descr_db()` a very short descr for a `duckdb` relation
85
87
  - `pivot_df()` gets a pivot table of a 3 column dataframe (or 2 columns if no weights are given)
@@ -89,7 +91,7 @@ tbl.show_num_df(
89
91
  - `pls` for plotly visualizations
90
92
  - `plot_box()` auto annotated boxplot w/ violin option
91
93
  - `plot_boxes()` multiple boxplots _(annotation is experimental)_
92
- - `plot_stacked_bars()` shortcut to stacked bars 😄
94
+ - `plot_stacked_bars()` shortcut to stacked bars
93
95
  - `plots_bars()` a standardized bar plot for a **categorical** column
94
96
  - features confidence intervals via `use_ci` option
95
97
  - `plot_histogram()` histogram for one or more **numerical** columns
@@ -105,7 +107,7 @@ tbl.show_num_df(
105
107
  <br>
106
108
 
107
109
  - `hlp` contains some (variety) helper functions
108
- - `to_series()` converts a dataframe to a series (`🚨 breaking change`)
110
+ - `to_series()` converts a dataframe to a series
109
111
  - `mean_confidence_interval()` calculates mean and confidence interval for a series
110
112
  - `wrap_text()` formats strings or lists to a given width to fit nicely on the screen
111
113
  - `replace_delimiter_outside_quotes()` when manual import of csv files is needed: replaces delimiters only outside of quotes
@@ -118,7 +120,13 @@ tbl.show_num_df(
118
120
  - `add_measures_to_pyg_config()` adds measures to a pygwalker config file to avoid frequent manual update
119
121
  <br>
120
122
 
121
- > note: theme setting can be controlled through all functions by setting the environment variable `THEME` to either light or dark
123
+ > note: theme setting ☀️ 🌔 can be controlled through all functions by setting the environment variable `THEME` to either light or dark
124
+
125
+ ## prerequisites
126
+
127
+ - ⚠️ for static image generation, this package uses Plotly's kaleido engine, which requires a system-wide installation of the Chrome or Chromium browser
128
+ - if image generation fails, it may be because a compatible browser is missing
129
+ - in such cases, please run `kaleido_get_chrome` from your terminal to install the necessary dependency.
122
130
 
123
131
  ## more examples
124
132
 
@@ -0,0 +1,9 @@
1
+ pandas_plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pandas_plots/hlp.py,sha256=z8rrVNbH9qMohdXPT-FksP-VkTOjI0bGFj47Sw5p3aY,21141
3
+ pandas_plots/pls.py,sha256=xA8Am76FUfGr4Sfq8YSSwDJfVTCtKLaDVVVH6o6YSIg,64691
4
+ pandas_plots/tbl.py,sha256=y_4ZFVogCRp4v8g6IKzxEnGVHdRUZbF0ACLugJW2_G8,33057
5
+ pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
6
+ pandas_plots-0.15.3.dist-info/METADATA,sha256=toYqCOH5bU0HGq5TVg_FGr4Zc1j2Ox5uX5A9lVlon70,7853
7
+ pandas_plots-0.15.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ pandas_plots-0.15.3.dist-info/licenses/LICENSE,sha256=ltLbQWUCs-GBQlTPXbt5nHNBE9U5LzjjoS1Y8hHETM4,1051
9
+ pandas_plots-0.15.3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pandas_plots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pandas_plots/hlp.py,sha256=z8rrVNbH9qMohdXPT-FksP-VkTOjI0bGFj47Sw5p3aY,21141
3
- pandas_plots/pls.py,sha256=k3btK4TWHUJCyHEzu3yLh40G9SuFlW84dYP2RLS5lWY,64118
4
- pandas_plots/tbl.py,sha256=mzrUif2TUZ8JJmkgzNpVYApBZS8L0MS1Yjpx9KZN7Vs,32920
5
- pandas_plots/ven.py,sha256=2x3ACo2vSfO3q6fv-UdDQ0h1SJyt8WChBGgE5SDCdCk,11673
6
- pandas_plots-0.15.1.dist-info/METADATA,sha256=xQ1FomsfZp38k4o_7J-Bp8dIkW3PvHM_wq4qK8QnWFU,7467
7
- pandas_plots-0.15.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pandas_plots-0.15.1.dist-info/licenses/LICENSE,sha256=ltLbQWUCs-GBQlTPXbt5nHNBE9U5LzjjoS1Y8hHETM4,1051
9
- pandas_plots-0.15.1.dist-info/RECORD,,