pandas-plots 0.11.23__tar.gz → 0.11.25__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pandas-plots
3
- Version: 0.11.23
4
- Summary: A collection of helper for table handling and vizualization
3
+ Version: 0.11.25
4
+ Summary: A collection of helper for table handling and visualization
5
5
  Home-page: https://github.com/smeisegeier/pandas-plots
6
6
  Author: smeisegeier
7
7
  Author-email: dexterDSDo@googlemail.com
@@ -29,7 +29,7 @@ Requires-Dist: requests>=2.32.0
29
29
  Requires-Dist: numpy<2.0.0
30
30
  Requires-Dist: missingno>=0.5.2
31
31
  Requires-Dist: duckdb>=1.0.0
32
- Requires-Dist: kaleido>=0.2.1
32
+ Requires-Dist: kaleido>=0.2.0
33
33
  Requires-Dist: nbformat>=4.2.0
34
34
 
35
35
  # pandas-plots
@@ -1,9 +1,9 @@
1
1
  [metadata]
2
2
  name = pandas-plots
3
- version = 0.11.23
3
+ version = 0.11.25
4
4
  author = smeisegeier
5
5
  author_email = dexterDSDo@googlemail.com
6
- description = A collection of helper for table handling and vizualization
6
+ description = A collection of helper for table handling and visualization
7
7
  long_description = file: README.md
8
8
  long_description_content_type = text/markdown
9
9
  license = MIT License
@@ -35,7 +35,7 @@ install_requires =
35
35
  numpy < 2.0.0
36
36
  missingno >= 0.5.2
37
37
  duckdb >= 1.0.0
38
- kaleido >= 0.2.1
38
+ kaleido >= 0.2.0
39
39
  nbformat >= 4.2.0
40
40
 
41
41
  [egg_info]
@@ -1,3 +1,4 @@
1
+ from pathlib import Path
1
2
  import warnings
2
3
 
3
4
  warnings.filterwarnings("ignore")
@@ -22,7 +23,8 @@ def plot_quadrants(
22
23
  df: pd.DataFrame,
23
24
  title: str = None,
24
25
  caption: str = None,
25
- ) -> None:
26
+ png_path: Path | str = None,
27
+ ) -> object:
26
28
  """
27
29
  Plot a heatmap for the given dataframe, with options for title and caption.
28
30
 
@@ -35,6 +37,7 @@ def plot_quadrants(
35
37
  df columns must contain 2 values
36
38
  title (str, optional): The title for the heatmap to override the default.
37
39
  caption (str, optional): The caption for the heatmap. Defaults to None.
40
+ png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
38
41
 
39
42
  Returns:
40
43
  q1, q2, q3, q4, n: The values for each quadrant and the total count.
@@ -93,6 +96,10 @@ def plot_quadrants(
93
96
  q3 = heat_wide_out.iloc[0, 0]
94
97
  q4 = heat_wide_out.iloc[0, 1]
95
98
 
99
+ # * save to png if path is provided
100
+ if png_path is not None:
101
+ plt.savefig(Path(png_path).as_posix(), format='png')
102
+
96
103
  return q1, q2, q3, q4, n
97
104
  # * plotly express is not used for the heatmap, although it does not need the derived wide format.
98
105
  # * but theres no option to alter inner values in the heatmap
@@ -115,7 +122,8 @@ def plot_stacked_bars(
115
122
  sort_values: bool = False,
116
123
  show_total: bool = False,
117
124
  precision: int = 0,
118
- ) -> None:
125
+ png_path: Path | str = None,
126
+ ) -> object:
119
127
  """
120
128
  Generates a stacked bar plot using the provided DataFrame.
121
129
  df *must* comprise the columns (order matters):
@@ -140,9 +148,10 @@ def plot_stacked_bars(
140
148
  - sort_values: bool = False - Sort axis by index (default) or values
141
149
  - show_total: bool = False - Whether to show the total value
142
150
  - precision: int = 0 - The number of decimal places to round to
151
+ - png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
143
152
 
144
153
  Returns:
145
- None
154
+ plot object
146
155
  """
147
156
  BAR_LENGTH_MULTIPLIER = 1.05
148
157
 
@@ -322,7 +331,12 @@ def plot_stacked_bars(
322
331
  _fig.update_layout(yaxis={"categoryorder": "category descending"})
323
332
 
324
333
  _fig.show(renderer)
325
- return
334
+
335
+ # * save to png if path is provided
336
+ if png_path is not None:
337
+ _fig.write_image(Path(png_path).as_posix())
338
+
339
+ return _fig
326
340
 
327
341
 
328
342
  def plot_bars(
@@ -340,7 +354,8 @@ def plot_bars(
340
354
  use_ci: bool = False,
341
355
  precision: int = 0,
342
356
  renderer: Literal["png", "svg", None] = "png",
343
- ) -> None:
357
+ png_path: Path | str = None,
358
+ ) -> object:
344
359
  """
345
360
  A function to plot a bar chart based on a *categorical* column (must be string or bool) and a numerical value.
346
361
  Accepts:
@@ -366,9 +381,10 @@ def plot_bars(
366
381
  - enforces dropna=True
367
382
  - precision: An integer indicating the number of decimal places to round the values to. Default is 0.
368
383
  - renderer: A string indicating the renderer to use for displaying the chart. It can be "png", "svg", or None. Default is "png".
384
+ - png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
369
385
 
370
386
  Returns:
371
- - None
387
+ - plot object
372
388
  """
373
389
  # * if series, apply value_counts, deselect use_ci
374
390
  if isinstance(df_in, pd.Series):
@@ -568,7 +584,12 @@ def plot_bars(
568
584
  textposition="outside" if not use_ci else "auto", error_y=dict(thickness=5)
569
585
  )
570
586
  _fig.show(renderer)
571
- return
587
+
588
+ # * save to png if path is provided
589
+ if png_path is not None:
590
+ _fig.write_image(Path(png_path).as_posix())
591
+
592
+ return _fig
572
593
 
573
594
 
574
595
  def plot_histogram(
@@ -586,7 +607,8 @@ def plot_histogram(
586
607
  renderer: Literal["png", "svg", None] = "png",
587
608
  caption: str = None,
588
609
  title: str = None,
589
- ) -> None:
610
+ png_path: Path | str = None,
611
+ ) -> object:
590
612
  """
591
613
  A function to plot a histogram based on *numeric* columns in a DataFrame.
592
614
  Accepts:
@@ -606,9 +628,11 @@ def plot_histogram(
606
628
  renderer (Literal["png", "svg", None]): The renderer for displaying the plot. Default is "png".
607
629
  caption (str): The caption for the plot. Default is None.
608
630
  title (str): The title of the plot. Default is None.
631
+ png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
632
+
609
633
 
610
634
  Returns:
611
- None
635
+ plot object
612
636
  """
613
637
 
614
638
  # * convert to df if series
@@ -657,7 +681,12 @@ def plot_histogram(
657
681
  )
658
682
 
659
683
  fig.show(renderer)
660
- return
684
+
685
+ # * save to png if path is provided
686
+ if png_path is not None:
687
+ fig.write_image(Path(png_path).as_posix())
688
+
689
+ return fig
661
690
 
662
691
 
663
692
  def plot_joint(
@@ -668,7 +697,8 @@ def plot_joint(
668
697
  dropna: bool = False,
669
698
  caption: str = "",
670
699
  title: str = "",
671
- ) -> None:
700
+ png_path: Path | str = None,
701
+ ) -> object:
672
702
  """
673
703
  Generate a seaborn joint plot for *two numeric* columns of a given DataFrame.
674
704
 
@@ -680,9 +710,10 @@ def plot_joint(
680
710
  - dropna: Whether to drop NA values before plotting (default is False).
681
711
  - caption: A caption for the plot.
682
712
  - title: The title of the plot.
713
+ - png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
683
714
 
684
715
  Returns:
685
- None
716
+ plot object
686
717
  """
687
718
 
688
719
  if df.shape[1] != 2:
@@ -750,7 +781,11 @@ def plot_joint(
750
781
  # dropna=dropna,
751
782
  # cmap=_cmap,
752
783
  # )
753
- return
784
+ # * save to png if path is provided
785
+ if png_path is not None:
786
+ fig.savefig(Path(png_path).as_posix())
787
+
788
+ return fig
754
789
 
755
790
 
756
791
  def plot_box(
@@ -766,7 +801,8 @@ def plot_box(
766
801
  violin: bool = False,
767
802
  x_min: float = None,
768
803
  x_max: float = None,
769
- ) -> None:
804
+ png_path: Path | str = None,
805
+ ) -> object:
770
806
  """
771
807
  Plots a horizontal box plot for the given pandas Series.
772
808
 
@@ -781,9 +817,10 @@ def plot_box(
781
817
  x_min: The minimum value for the x-axis scale (max and min must be set)
782
818
  x_max: The maximum value for the x-axis scale (max and min must be set)
783
819
  summary: Whether to add a summary table to the plot
820
+ png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
784
821
 
785
822
  Returns:
786
- None
823
+ plot object
787
824
  """
788
825
  ser = to_series(ser)
789
826
  if ser is None:
@@ -896,9 +933,15 @@ def plot_box(
896
933
  )
897
934
 
898
935
  fig.show("png")
936
+
899
937
  if summary:
900
938
  print_summary(ser)
901
- return
939
+
940
+ # * save to png if path is provided
941
+ if png_path is not None:
942
+ fig.write_image(Path(png_path).as_posix())
943
+
944
+ return fig
902
945
 
903
946
 
904
947
  def plot_boxes(
@@ -911,7 +954,8 @@ def plot_boxes(
911
954
  annotations: bool = True,
912
955
  summary: bool = True,
913
956
  title: str = None,
914
- ) -> None:
957
+ png_path: Path | str = None,
958
+ ) -> object:
915
959
  """
916
960
  [Experimental] Plot vertical boxes for each unique item in the DataFrame and add annotations for statistics.
917
961
 
@@ -924,9 +968,10 @@ def plot_boxes(
924
968
  width (int): The width of the plot.
925
969
  annotations (bool): Whether to add annotations to the plot.
926
970
  summary (bool): Whether to add a summary to the plot.
971
+ png_path (Path | str, optional): The path to save the image as a png file. Defaults to None.
927
972
 
928
973
  Returns:
929
- None
974
+ plot object
930
975
  """
931
976
 
932
977
  if (
@@ -1039,7 +1084,12 @@ def plot_boxes(
1039
1084
  fig.show("png")
1040
1085
  if summary:
1041
1086
  print_summary(df)
1042
- return
1087
+
1088
+ # * save to png if path is provided
1089
+ if png_path is not None:
1090
+ fig.write_image(Path(png_path).as_posix())
1091
+
1092
+ return fig
1043
1093
 
1044
1094
 
1045
1095
  # def plot_ci_bars_DEPR(df: pd.DataFrame, dropna: bool = True, precision: int = 2) -> None:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pandas-plots
3
- Version: 0.11.23
4
- Summary: A collection of helper for table handling and vizualization
3
+ Version: 0.11.25
4
+ Summary: A collection of helper for table handling and visualization
5
5
  Home-page: https://github.com/smeisegeier/pandas-plots
6
6
  Author: smeisegeier
7
7
  Author-email: dexterDSDo@googlemail.com
@@ -29,7 +29,7 @@ Requires-Dist: requests>=2.32.0
29
29
  Requires-Dist: numpy<2.0.0
30
30
  Requires-Dist: missingno>=0.5.2
31
31
  Requires-Dist: duckdb>=1.0.0
32
- Requires-Dist: kaleido>=0.2.1
32
+ Requires-Dist: kaleido>=0.2.0
33
33
  Requires-Dist: nbformat>=4.2.0
34
34
 
35
35
  # pandas-plots
@@ -8,5 +8,5 @@ requests>=2.32.0
8
8
  numpy<2.0.0
9
9
  missingno>=0.5.2
10
10
  duckdb>=1.0.0
11
- kaleido>=0.2.1
11
+ kaleido>=0.2.0
12
12
  nbformat>=4.2.0
File without changes
File without changes