polars-data-profiling 0.1.0__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.
Files changed (207) hide show
  1. polars_data_profiling/__init__.py +19 -0
  2. polars_data_profiling/compare_reports.py +386 -0
  3. polars_data_profiling/config.py +558 -0
  4. polars_data_profiling/config_default.yaml +219 -0
  5. polars_data_profiling/config_minimal.yaml +218 -0
  6. polars_data_profiling/controller/__init__.py +1 -0
  7. polars_data_profiling/controller/console.py +127 -0
  8. polars_data_profiling/controller/namespace.py +38 -0
  9. polars_data_profiling/model/__init__.py +5 -0
  10. polars_data_profiling/model/alerts.py +779 -0
  11. polars_data_profiling/model/correlations.py +332 -0
  12. polars_data_profiling/model/dataframe.py +24 -0
  13. polars_data_profiling/model/describe.py +197 -0
  14. polars_data_profiling/model/description.py +106 -0
  15. polars_data_profiling/model/duplicates.py +64 -0
  16. polars_data_profiling/model/engine.py +192 -0
  17. polars_data_profiling/model/expressions.py +215 -0
  18. polars_data_profiling/model/handler.py +84 -0
  19. polars_data_profiling/model/images.py +179 -0
  20. polars_data_profiling/model/missing.py +161 -0
  21. polars_data_profiling/model/pairwise.py +59 -0
  22. polars_data_profiling/model/probe.py +217 -0
  23. polars_data_profiling/model/sample.py +77 -0
  24. polars_data_profiling/model/summaries.py +641 -0
  25. polars_data_profiling/model/summarizer.py +177 -0
  26. polars_data_profiling/model/summary.py +143 -0
  27. polars_data_profiling/model/summary_algorithms.py +301 -0
  28. polars_data_profiling/model/table.py +47 -0
  29. polars_data_profiling/model/timeseries.py +312 -0
  30. polars_data_profiling/model/timeseries_index.py +48 -0
  31. polars_data_profiling/model/type_rules.py +35 -0
  32. polars_data_profiling/model/typeset.py +262 -0
  33. polars_data_profiling/model/typeset_base.py +367 -0
  34. polars_data_profiling/model/typeset_relations.py +132 -0
  35. polars_data_profiling/profile_report.py +508 -0
  36. polars_data_profiling/py.typed +0 -0
  37. polars_data_profiling/report/__init__.py +5 -0
  38. polars_data_profiling/report/formatters.py +344 -0
  39. polars_data_profiling/report/presentation/__init__.py +1 -0
  40. polars_data_profiling/report/presentation/core/__init__.py +43 -0
  41. polars_data_profiling/report/presentation/core/alerts.py +18 -0
  42. polars_data_profiling/report/presentation/core/collapse.py +25 -0
  43. polars_data_profiling/report/presentation/core/container.py +51 -0
  44. polars_data_profiling/report/presentation/core/correlation_table.py +21 -0
  45. polars_data_profiling/report/presentation/core/dropdown.py +45 -0
  46. polars_data_profiling/report/presentation/core/duplicate.py +16 -0
  47. polars_data_profiling/report/presentation/core/frequency_table.py +14 -0
  48. polars_data_profiling/report/presentation/core/frequency_table_small.py +16 -0
  49. polars_data_profiling/report/presentation/core/html.py +14 -0
  50. polars_data_profiling/report/presentation/core/image.py +34 -0
  51. polars_data_profiling/report/presentation/core/item_renderer.py +16 -0
  52. polars_data_profiling/report/presentation/core/renderable.py +42 -0
  53. polars_data_profiling/report/presentation/core/root.py +36 -0
  54. polars_data_profiling/report/presentation/core/sample.py +29 -0
  55. polars_data_profiling/report/presentation/core/scores.py +33 -0
  56. polars_data_profiling/report/presentation/core/table.py +27 -0
  57. polars_data_profiling/report/presentation/core/toggle_button.py +14 -0
  58. polars_data_profiling/report/presentation/core/variable.py +51 -0
  59. polars_data_profiling/report/presentation/core/variable_info.py +36 -0
  60. polars_data_profiling/report/presentation/flavours/__init__.py +9 -0
  61. polars_data_profiling/report/presentation/flavours/flavour_html.py +65 -0
  62. polars_data_profiling/report/presentation/flavours/flavour_widget.py +62 -0
  63. polars_data_profiling/report/presentation/flavours/flavours.py +42 -0
  64. polars_data_profiling/report/presentation/flavours/html/__init__.py +57 -0
  65. polars_data_profiling/report/presentation/flavours/html/alerts.py +10 -0
  66. polars_data_profiling/report/presentation/flavours/html/collapse.py +7 -0
  67. polars_data_profiling/report/presentation/flavours/html/container.py +85 -0
  68. polars_data_profiling/report/presentation/flavours/html/correlation_table.py +21 -0
  69. polars_data_profiling/report/presentation/flavours/html/dropdown.py +7 -0
  70. polars_data_profiling/report/presentation/flavours/html/duplicate.py +23 -0
  71. polars_data_profiling/report/presentation/flavours/html/frame_table.py +61 -0
  72. polars_data_profiling/report/presentation/flavours/html/frequency_table.py +20 -0
  73. polars_data_profiling/report/presentation/flavours/html/frequency_table_small.py +15 -0
  74. polars_data_profiling/report/presentation/flavours/html/html.py +6 -0
  75. polars_data_profiling/report/presentation/flavours/html/image.py +7 -0
  76. polars_data_profiling/report/presentation/flavours/html/root.py +15 -0
  77. polars_data_profiling/report/presentation/flavours/html/sample.py +17 -0
  78. polars_data_profiling/report/presentation/flavours/html/scores.py +12 -0
  79. polars_data_profiling/report/presentation/flavours/html/table.py +7 -0
  80. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant.html +1 -0
  81. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant_length.html +1 -0
  82. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_dirty_category.html +1 -0
  83. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_duplicates.html +1 -0
  84. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_empty.html +1 -0
  85. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_cardinality.html +1 -0
  86. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_correlation.html +4 -0
  87. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_imbalance.html +1 -0
  88. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_infinite.html +1 -0
  89. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_missing.html +1 -0
  90. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_near_duplicates.html +1 -0
  91. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_non_stationary.html +1 -0
  92. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_seasonal.html +1 -0
  93. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_skewed.html +1 -0
  94. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_truncated.html +1 -0
  95. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_type_date.html +1 -0
  96. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_uniform.html +1 -0
  97. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_unique.html +1 -0
  98. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_unsupported.html +1 -0
  99. polars_data_profiling/report/presentation/flavours/html/templates/alerts/alert_zeros.html +1 -0
  100. polars_data_profiling/report/presentation/flavours/html/templates/alerts.html +47 -0
  101. polars_data_profiling/report/presentation/flavours/html/templates/collapse.html +31 -0
  102. polars_data_profiling/report/presentation/flavours/html/templates/correlation_table.html +5 -0
  103. polars_data_profiling/report/presentation/flavours/html/templates/diagram.html +13 -0
  104. polars_data_profiling/report/presentation/flavours/html/templates/dropdown.html +25 -0
  105. polars_data_profiling/report/presentation/flavours/html/templates/duplicate.html +5 -0
  106. polars_data_profiling/report/presentation/flavours/html/templates/frequency_table.html +45 -0
  107. polars_data_profiling/report/presentation/flavours/html/templates/frequency_table_small.html +34 -0
  108. polars_data_profiling/report/presentation/flavours/html/templates/report.html +42 -0
  109. polars_data_profiling/report/presentation/flavours/html/templates/sample.html +10 -0
  110. polars_data_profiling/report/presentation/flavours/html/templates/scores.html +78 -0
  111. polars_data_profiling/report/presentation/flavours/html/templates/sequence/batch_grid.html +16 -0
  112. polars_data_profiling/report/presentation/flavours/html/templates/sequence/cards.html +41 -0
  113. polars_data_profiling/report/presentation/flavours/html/templates/sequence/correlations.html +53 -0
  114. polars_data_profiling/report/presentation/flavours/html/templates/sequence/grid.html +39 -0
  115. polars_data_profiling/report/presentation/flavours/html/templates/sequence/interactions.html +45 -0
  116. polars_data_profiling/report/presentation/flavours/html/templates/sequence/list.html +7 -0
  117. polars_data_profiling/report/presentation/flavours/html/templates/sequence/named_list.html +8 -0
  118. polars_data_profiling/report/presentation/flavours/html/templates/sequence/overview_tabs.html +47 -0
  119. polars_data_profiling/report/presentation/flavours/html/templates/sequence/scores.html +3 -0
  120. polars_data_profiling/report/presentation/flavours/html/templates/sequence/sections.html +15 -0
  121. polars_data_profiling/report/presentation/flavours/html/templates/sequence/select.html +40 -0
  122. polars_data_profiling/report/presentation/flavours/html/templates/sequence/tabs.html +30 -0
  123. polars_data_profiling/report/presentation/flavours/html/templates/table.html +38 -0
  124. polars_data_profiling/report/presentation/flavours/html/templates/toggle_button.html +18 -0
  125. polars_data_profiling/report/presentation/flavours/html/templates/variable.html +7 -0
  126. polars_data_profiling/report/presentation/flavours/html/templates/variable_info.html +49 -0
  127. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.bundle.min.js +7 -0
  128. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.min.css +6 -0
  129. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/cosmo.bootstrap.min.css +12 -0
  130. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/flatly.bootstrap.min.css +12 -0
  131. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/script.js +398 -0
  132. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/simplex.bootstrap.min.css +12 -0
  133. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/style.css +1455 -0
  134. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/assets/united.bootstrap.min.css +12 -0
  135. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/footer.html +6 -0
  136. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/javascript.html +18 -0
  137. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/navigation.html +22 -0
  138. polars_data_profiling/report/presentation/flavours/html/templates/wrapper/style.html +20 -0
  139. polars_data_profiling/report/presentation/flavours/html/templates.py +79 -0
  140. polars_data_profiling/report/presentation/flavours/html/theme.py +74 -0
  141. polars_data_profiling/report/presentation/flavours/html/toggle_button.py +7 -0
  142. polars_data_profiling/report/presentation/flavours/html/variable.py +7 -0
  143. polars_data_profiling/report/presentation/flavours/html/variable_info.py +7 -0
  144. polars_data_profiling/report/presentation/flavours/widget/__init__.py +59 -0
  145. polars_data_profiling/report/presentation/flavours/widget/alerts.py +43 -0
  146. polars_data_profiling/report/presentation/flavours/widget/collapse.py +43 -0
  147. polars_data_profiling/report/presentation/flavours/widget/container.py +127 -0
  148. polars_data_profiling/report/presentation/flavours/widget/correlation_table.py +16 -0
  149. polars_data_profiling/report/presentation/flavours/widget/dropdown.py +31 -0
  150. polars_data_profiling/report/presentation/flavours/widget/duplicate.py +14 -0
  151. polars_data_profiling/report/presentation/flavours/widget/frequency_table.py +57 -0
  152. polars_data_profiling/report/presentation/flavours/widget/frequency_table_small.py +64 -0
  153. polars_data_profiling/report/presentation/flavours/widget/html.py +11 -0
  154. polars_data_profiling/report/presentation/flavours/widget/image.py +29 -0
  155. polars_data_profiling/report/presentation/flavours/widget/notebook.py +82 -0
  156. polars_data_profiling/report/presentation/flavours/widget/root.py +10 -0
  157. polars_data_profiling/report/presentation/flavours/widget/sample.py +14 -0
  158. polars_data_profiling/report/presentation/flavours/widget/table.py +30 -0
  159. polars_data_profiling/report/presentation/flavours/widget/toggle_button.py +17 -0
  160. polars_data_profiling/report/presentation/flavours/widget/variable.py +12 -0
  161. polars_data_profiling/report/presentation/flavours/widget/variable_info.py +11 -0
  162. polars_data_profiling/report/presentation/frequency_table_utils.py +169 -0
  163. polars_data_profiling/report/structure/__init__.py +1 -0
  164. polars_data_profiling/report/structure/correlations.py +202 -0
  165. polars_data_profiling/report/structure/overview.py +506 -0
  166. polars_data_profiling/report/structure/report.py +547 -0
  167. polars_data_profiling/report/structure/variables/__init__.py +41 -0
  168. polars_data_profiling/report/structure/variables/render_boolean.py +130 -0
  169. polars_data_profiling/report/structure/variables/render_categorical.py +562 -0
  170. polars_data_profiling/report/structure/variables/render_common.py +34 -0
  171. polars_data_profiling/report/structure/variables/render_complex.py +102 -0
  172. polars_data_profiling/report/structure/variables/render_count.py +172 -0
  173. polars_data_profiling/report/structure/variables/render_date.py +147 -0
  174. polars_data_profiling/report/structure/variables/render_file.py +68 -0
  175. polars_data_profiling/report/structure/variables/render_generic.py +45 -0
  176. polars_data_profiling/report/structure/variables/render_image.py +202 -0
  177. polars_data_profiling/report/structure/variables/render_path.py +138 -0
  178. polars_data_profiling/report/structure/variables/render_real.py +314 -0
  179. polars_data_profiling/report/structure/variables/render_text.py +213 -0
  180. polars_data_profiling/report/structure/variables/render_timeseries.py +371 -0
  181. polars_data_profiling/report/structure/variables/render_url.py +132 -0
  182. polars_data_profiling/report/utils.py +32 -0
  183. polars_data_profiling/serialize_report.py +144 -0
  184. polars_data_profiling/utils/__init__.py +1 -0
  185. polars_data_profiling/utils/collect.py +41 -0
  186. polars_data_profiling/utils/common.py +29 -0
  187. polars_data_profiling/utils/dataframe.py +166 -0
  188. polars_data_profiling/utils/notebook.py +8 -0
  189. polars_data_profiling/utils/paths.py +46 -0
  190. polars_data_profiling/utils/progress_bar.py +16 -0
  191. polars_data_profiling/utils/styles.py +22 -0
  192. polars_data_profiling/version.py +8 -0
  193. polars_data_profiling/visualisation/__init__.py +1 -0
  194. polars_data_profiling/visualisation/charts/__init__.py +16 -0
  195. polars_data_profiling/visualisation/charts/builders.py +631 -0
  196. polars_data_profiling/visualisation/charts/palette.py +129 -0
  197. polars_data_profiling/visualisation/charts/scales.py +204 -0
  198. polars_data_profiling/visualisation/charts/specs.py +249 -0
  199. polars_data_profiling/visualisation/charts/svg.py +1336 -0
  200. polars_data_profiling/visualisation/missing.py +34 -0
  201. polars_data_profiling/visualisation/plot.py +142 -0
  202. polars_data_profiling-0.1.0.dist-info/METADATA +131 -0
  203. polars_data_profiling-0.1.0.dist-info/RECORD +207 -0
  204. polars_data_profiling-0.1.0.dist-info/WHEEL +4 -0
  205. polars_data_profiling-0.1.0.dist-info/entry_points.txt +3 -0
  206. polars_data_profiling-0.1.0.dist-info/licenses/LICENSE +22 -0
  207. polars_data_profiling-0.1.0.dist-info/licenses/NOTICE +26 -0
@@ -0,0 +1,558 @@
1
+ """Configuration for the package."""
2
+
3
+ import warnings
4
+ from enum import Enum
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ import yaml
9
+ from pydantic import BaseModel as _PydanticModel
10
+ from pydantic import ConfigDict, Field, PrivateAttr, field_validator
11
+ from pydantic_settings import BaseSettings, SettingsConfigDict
12
+
13
+
14
+ class BaseModel(_PydanticModel):
15
+ """Base of the settings models.
16
+
17
+ Numbers are accepted for string settings (``copyright_year: 2024`` in a
18
+ YAML file) and unknown nested keys are ignored, as with pydantic 1, so
19
+ configurations written for ydata-profiling (with settings this fork
20
+ removed, such as ``plot.dpi``) still load. Unknown top-level settings
21
+ are errors.
22
+ """
23
+
24
+ model_config = ConfigDict(coerce_numbers_to_str=True, extra="ignore")
25
+
26
+
27
+ def _merge_dictionaries(dict1: dict, dict2: dict) -> dict:
28
+ """
29
+ Recursive merge dictionaries.
30
+
31
+ :param dict1: Base dictionary to merge.
32
+ :param dict2: Dictionary to merge on top of base dictionary.
33
+ :return: Merged dictionary
34
+ """
35
+ for key, val in dict1.items():
36
+ if isinstance(val, dict):
37
+ dict2_node = dict2.setdefault(key, {})
38
+ _merge_dictionaries(val, dict2_node)
39
+ else:
40
+ if key not in dict2:
41
+ dict2[key] = val
42
+
43
+ return dict2
44
+
45
+
46
+ class Dataset(BaseModel):
47
+ """Metadata of the dataset"""
48
+
49
+ description: str = ""
50
+ creator: str = ""
51
+ author: str = ""
52
+ copyright_holder: str = ""
53
+ copyright_year: str = ""
54
+ url: str = ""
55
+
56
+
57
+ class NumVars(BaseModel):
58
+ quantiles: list[float] = [0.05, 0.25, 0.5, 0.75, 0.95]
59
+ skewness_threshold: int = 20
60
+ low_categorical_threshold: int = 5
61
+ # Set to zero to disable
62
+ chi_squared_threshold: float = 0.999
63
+
64
+
65
+ class TextVars(BaseModel):
66
+ length: bool = True
67
+ words: bool = True
68
+ characters: bool = True
69
+ redact: bool = False
70
+
71
+
72
+ class CatVars(BaseModel):
73
+ length: bool = True
74
+ characters: bool = True
75
+ words: bool = True
76
+ # if var has more than threshold categories, it's a text var
77
+ cardinality_threshold: int = 50
78
+ # if var has more than threshold % distinct values, it's a text var
79
+ percentage_cat_threshold: float = 0.5
80
+ imbalance_threshold: float = 0.5
81
+ n_obs: int = 5
82
+ # Set to zero to disable
83
+ chi_squared_threshold: float = 0.999
84
+ coerce_str_to_date: bool = False
85
+ redact: bool = False
86
+ histogram_largest: int = 50
87
+ stop_words: list[str] = []
88
+ dirty_categories: bool = False
89
+ dirty_categories_threshold: float = 0.85
90
+
91
+
92
+ class BoolVars(BaseModel):
93
+ n_obs: int = 3
94
+ imbalance_threshold: float = 0.5
95
+
96
+ # string to boolean mapping dict
97
+ mappings: dict[str, bool] = {
98
+ "t": True,
99
+ "f": False,
100
+ "yes": True,
101
+ "no": False,
102
+ "y": True,
103
+ "n": False,
104
+ "true": True,
105
+ "false": False,
106
+ }
107
+
108
+
109
+ class FileVars(BaseModel):
110
+ active: bool = False
111
+
112
+
113
+ class PathVars(BaseModel):
114
+ active: bool = False
115
+
116
+
117
+ class ImageVars(BaseModel):
118
+ active: bool = False
119
+ exif: bool = True
120
+ hash: bool = True
121
+
122
+
123
+ class UrlVars(BaseModel):
124
+ active: bool = False
125
+
126
+
127
+ class TimeseriesVars(BaseModel):
128
+ active: bool = False
129
+ sortby: str | None = None
130
+ autocorrelation: float = 0.7
131
+ lags: list[int] = [1, 7, 12, 24, 30]
132
+ significance: float = 0.05
133
+ pacf_acf_lag: int = 100
134
+ autolag: str | None = "AIC"
135
+ maxlag: int | None = None
136
+
137
+
138
+ class Univariate(BaseModel):
139
+ num: NumVars = NumVars()
140
+ text: TextVars = TextVars()
141
+ cat: CatVars = CatVars()
142
+ image: ImageVars = ImageVars()
143
+ bool: BoolVars = BoolVars()
144
+ path: PathVars = PathVars()
145
+ file: FileVars = FileVars()
146
+ url: UrlVars = UrlVars()
147
+ timeseries: TimeseriesVars = TimeseriesVars()
148
+
149
+
150
+ class MissingPlot(BaseModel):
151
+ # Force labels when there are > 50 variables
152
+ force_labels: bool = True
153
+ cmap: str = "RdBu"
154
+
155
+
156
+ class ImageType(Enum):
157
+ """Format of the charts. Charts are always inline SVG."""
158
+
159
+ svg = "svg"
160
+
161
+
162
+ class CorrelationPlot(BaseModel):
163
+ cmap: str = "RdBu"
164
+ bad: str = "#000000"
165
+
166
+
167
+ class Histogram(BaseModel):
168
+ # Number of bins (set to 0 to automatically detect the bin size)
169
+ bins: int = 50
170
+ # Maximum number of bins (when bins=0)
171
+ max_bins: int = 250
172
+ x_axis_labels: bool = True
173
+ density: bool = False
174
+
175
+
176
+ class CatFrequencyPlot(BaseModel):
177
+ show: bool = True # if false, the category frequency plot is turned off
178
+ type: str = "bar" # options: 'bar', 'pie'
179
+
180
+ # The cat frequency plot is only rendered if the number of distinct values is
181
+ # smaller or equal to "max_unique"
182
+ max_unique: int = 10
183
+
184
+ # Colors: a list of CSS colours (hex such as "#1f77b4" or names); the
185
+ # report palette is used when unset
186
+ colors: list[str] | None = None
187
+
188
+
189
+ class Plot(BaseModel):
190
+ missing: MissingPlot = MissingPlot()
191
+ # Charts are inline SVG; kept as a setting for compatibility
192
+ image_format: ImageType = ImageType.svg
193
+ correlation: CorrelationPlot = CorrelationPlot()
194
+ histogram: Histogram = Histogram()
195
+ scatter_threshold: int = 1000
196
+ cat_freq: CatFrequencyPlot = CatFrequencyPlot()
197
+ # Font used to lay out word clouds (optional `wordcloud` extra)
198
+ font_path: Path | str | None = None
199
+
200
+
201
+ class Theme(Enum):
202
+ light = "light"
203
+ dark = "dark"
204
+ # Follows the viewer's operating-system preference (prefers-color-scheme)
205
+ auto = "auto"
206
+ # Deprecated Bootswatch themes: rendered as ``light`` with the theme's
207
+ # brand colour as accent (see ``LEGACY_THEME_ACCENTS``).
208
+ united = "united"
209
+ flatly = "flatly"
210
+ cosmo = "cosmo"
211
+ simplex = "simplex"
212
+
213
+
214
+ LEGACY_THEME_ACCENTS = {
215
+ "united": "#e95420",
216
+ "flatly": "#2c3e50",
217
+ "cosmo": "#2780e3",
218
+ "simplex": "#d9230f",
219
+ }
220
+ DEFAULT_PRIMARY_COLORS = ["#0d6efd", "#dc3545", "#198754"]
221
+
222
+
223
+ class Style(BaseModel):
224
+ # Primary color used for plotting and text where applicable.
225
+ @property
226
+ def primary_color(self) -> str:
227
+ # This attribute may be deprecated in the future, please use primary_colors[0]
228
+ return self.primary_colors[0]
229
+
230
+ # Primary color used for comparisons (default: blue, red, green).
231
+ # The first colour is also the accent of the HTML report (links, buttons).
232
+ primary_colors: list[str] = list(DEFAULT_PRIMARY_COLORS)
233
+
234
+ # Base64-encoded logo image
235
+ logo: str = ""
236
+
237
+ # HTML theme: light (default when None), dark or auto. The Bootswatch
238
+ # themes (united, flatly, cosmo, simplex) are deprecated.
239
+ theme: Theme | None = None
240
+
241
+ # Let the host page show through the report background (useful when the
242
+ # report is embedded in notebooks, apps or iframes).
243
+ transparent_background: bool = False
244
+
245
+ @field_validator("theme", mode="before")
246
+ @classmethod
247
+ def _warn_legacy_theme(cls, value: Any) -> Any:
248
+ name = value.value if isinstance(value, Theme) else value
249
+ if isinstance(name, str) and name in LEGACY_THEME_ACCENTS:
250
+ warnings.warn(
251
+ f"The '{name}' HTML theme is deprecated and will be removed in a "
252
+ "future release. The report now uses the light theme with "
253
+ f"'{LEGACY_THEME_ACCENTS[name]}' as accent; use theme 'light', "
254
+ "'dark' or 'auto' and html.style.primary_colors instead.",
255
+ FutureWarning,
256
+ stacklevel=2,
257
+ )
258
+ return value
259
+
260
+ @property
261
+ def theme_mode(self) -> str:
262
+ """Colour mode of the HTML report: ``light``, ``dark`` or ``auto``."""
263
+ if self.theme in (Theme.dark, Theme.auto):
264
+ return self.theme.value
265
+ return "light"
266
+
267
+ @property
268
+ def accent_color(self) -> str:
269
+ """Accent colour of the HTML report.
270
+
271
+ The first primary colour, unless a deprecated theme was selected while
272
+ the primary colours were left at their defaults.
273
+ """
274
+ if (
275
+ self.theme is not None
276
+ and self.theme.value in LEGACY_THEME_ACCENTS
277
+ and list(self.primary_colors) == DEFAULT_PRIMARY_COLORS
278
+ ):
279
+ return LEGACY_THEME_ACCENTS[self.theme.value]
280
+ return self.primary_colors[0]
281
+
282
+ # Labels used for comparing reports (private attribute)
283
+ _labels: list[str] = PrivateAttr(["_"])
284
+
285
+
286
+ class Html(BaseModel):
287
+ # Styling options for the HTML report
288
+ style: Style = Style()
289
+
290
+ # Show navbar
291
+ navbar_show: bool = True
292
+
293
+ # Minify the html
294
+ minify_html: bool = True
295
+
296
+ # Offline support
297
+ use_local_assets: bool = True
298
+
299
+ # If True, single file, else directory with assets
300
+ inline: bool = True
301
+
302
+ # Assets prefix if inline = True
303
+ assets_prefix: str | None = None
304
+
305
+ # Internal usage
306
+ assets_path: str | None = None
307
+
308
+ full_width: bool = False
309
+
310
+
311
+ class Duplicates(BaseModel):
312
+ head: int = 10
313
+ key: str = "# duplicates"
314
+
315
+
316
+ class Correlation(BaseModel):
317
+ key: str = ""
318
+ calculate: bool = Field(default=True)
319
+ warn_high_correlations: int = Field(default=10)
320
+ threshold: float = Field(default=0.5)
321
+ n_bins: int = Field(default=10)
322
+
323
+
324
+ class Correlations(BaseModel):
325
+ pearson: Correlation = Correlation(key="pearson")
326
+ spearman: Correlation = Correlation(key="spearman")
327
+ auto: Correlation = Correlation(key="auto")
328
+
329
+
330
+ class Interactions(BaseModel):
331
+ # Set to False to disable scatter plots
332
+ continuous: bool = True
333
+
334
+ targets: list[str] = []
335
+
336
+
337
+ class Samples(BaseModel):
338
+ head: int = 10
339
+ tail: int = 10
340
+ random: int = 0
341
+
342
+
343
+ class Variables(BaseModel):
344
+ descriptions: dict = {}
345
+
346
+
347
+ class IframeAttribute(Enum):
348
+ src = "src"
349
+ srcdoc = "srcdoc"
350
+
351
+
352
+ class Iframe(BaseModel):
353
+ height: str = "800px"
354
+ width: str = "100%"
355
+ attribute: IframeAttribute = IframeAttribute.srcdoc
356
+
357
+
358
+ class Notebook(BaseModel):
359
+ """When in a Jupyter notebook"""
360
+
361
+ iframe: Iframe = Iframe()
362
+
363
+
364
+ class Engine(BaseModel):
365
+ """How the lazy queries of a profile are executed."""
366
+
367
+ # Each batch of queries reads the source once, through a cache node shared by
368
+ # the queries (a profile then reads its source about a dozen times, whatever
369
+ # its number of columns). Off: every query scans only the columns it needs,
370
+ # which lowers peak memory on very large Parquet files at the cost of more
371
+ # reads.
372
+ share_scans: bool = True
373
+ # Polars engine used to collect: "auto", "in-memory", "streaming" or "gpu"
374
+ collect_engine: str = "auto"
375
+
376
+
377
+ class Report(BaseModel):
378
+ # Numeric precision for displaying statistics
379
+ precision: int = 8
380
+
381
+
382
+ class Settings(BaseSettings):
383
+ # Settings can also come from PROFILE_* environment variables
384
+ model_config = SettingsConfigDict(
385
+ env_prefix="profile_", extra="forbid", coerce_numbers_to_str=True
386
+ )
387
+
388
+ # Title of the document
389
+ title: str = "Profiling Report"
390
+
391
+ dataset: Dataset = Dataset()
392
+ variables: Variables = Variables()
393
+ infer_dtypes: bool = True
394
+
395
+ # Show the description at each variable (in addition to the overview tab)
396
+ show_variable_description: bool = True
397
+
398
+ # Number of workers (0=multiprocessing.cpu_count())
399
+ pool_size: int = 0
400
+
401
+ # Show the progress bar
402
+ progress_bar: bool = True
403
+
404
+ # Per variable type description settings
405
+ vars: Univariate = Univariate()
406
+
407
+ # Sort the variables. Possible values: ascending, descending or None (leaves original sorting)
408
+ sort: str | None = None
409
+
410
+ missing_diagrams: dict[str, bool] = {
411
+ "bar": True,
412
+ "matrix": True,
413
+ "heatmap": True,
414
+ }
415
+
416
+ correlation_table: bool = True
417
+
418
+ correlations: dict[str, Correlation] = {
419
+ "auto": Correlation(key="auto", calculate=True),
420
+ "spearman": Correlation(key="spearman", calculate=False),
421
+ "pearson": Correlation(key="pearson", calculate=False),
422
+ "cramers": Correlation(key="cramers", calculate=False),
423
+ "kendall": Correlation(key="kendall", calculate=False),
424
+ }
425
+
426
+ interactions: Interactions = Interactions()
427
+
428
+ categorical_maximum_correlation_distinct: int = 100
429
+ # Use `deep` flag for memory_usage
430
+ memory_deep: bool = False
431
+ plot: Plot = Plot()
432
+ duplicates: Duplicates = Duplicates()
433
+ samples: Samples = Samples()
434
+
435
+ reject_variables: bool = True
436
+
437
+ # The number of observations to show
438
+ n_obs_unique: int = 10
439
+ n_freq_table_max: int = 10
440
+ n_extreme_obs: int = 10
441
+
442
+ # Query execution
443
+ engine: Engine = Engine()
444
+
445
+ # Report rendering
446
+ report: Report = Report()
447
+ html: Html = Html()
448
+ notebook: Notebook = Notebook()
449
+
450
+ def update(self, updates: dict) -> "Settings":
451
+ """A copy of these settings with ``updates`` merged in (nested dicts
452
+ are merged key by key)."""
453
+ update = _merge_dictionaries(self.model_dump(), updates)
454
+ return type(self).model_validate(update)
455
+
456
+ @staticmethod
457
+ def from_file(config_file: Path | str) -> "Settings":
458
+ """Create a Settings object from a yaml file.
459
+
460
+ Args:
461
+ config_file: yaml file path
462
+ Returns:
463
+ Settings
464
+ """
465
+ with open(config_file) as f:
466
+ data = yaml.safe_load(f)
467
+
468
+ return Settings.model_validate(data)
469
+
470
+
471
+ class Config:
472
+ arg_groups: dict[str, Any] = {
473
+ "sensitive": {
474
+ "samples": None,
475
+ "duplicates": None,
476
+ "vars": {"cat": {"redact": True}, "text": {"redact": True}},
477
+ },
478
+ # Kept for backwards compatibility: the Bootswatch themes are gone,
479
+ # these presets now only set the accent colour.
480
+ "flatly_theme": {
481
+ "html": {
482
+ "style": {
483
+ "theme": Theme.light,
484
+ "primary_colors": ["#2c3e50", "#e74c3c", "#18bc9c"],
485
+ }
486
+ }
487
+ },
488
+ "united_theme": {
489
+ "html": {
490
+ "style": {
491
+ "theme": Theme.light,
492
+ "primary_colors": ["#d34615", "#772953", "#38b44a"],
493
+ }
494
+ }
495
+ },
496
+ "explorative": {
497
+ "vars": {
498
+ "cat": {"characters": True, "words": True},
499
+ "url": {"active": True},
500
+ "path": {"active": True},
501
+ "file": {"active": True},
502
+ "image": {"active": True},
503
+ },
504
+ "n_obs_unique": 10,
505
+ "n_extreme_obs": 10,
506
+ "n_freq_table_max": 10,
507
+ "memory_deep": True,
508
+ },
509
+ }
510
+
511
+ _shorthands = {
512
+ "dataset": {
513
+ "creator": "",
514
+ "author": "",
515
+ "description": "",
516
+ "copyright_holder": "",
517
+ "copyright_year": "",
518
+ "url": "",
519
+ },
520
+ "samples": {"head": 0, "tail": 0, "random": 0},
521
+ "duplicates": {"head": 0},
522
+ "interactions": {"targets": [], "continuous": False},
523
+ "missing_diagrams": {
524
+ "bar": False,
525
+ "matrix": False,
526
+ "heatmap": False,
527
+ },
528
+ "correlations": {
529
+ "auto": {"calculate": False},
530
+ "pearson": {"calculate": False},
531
+ "spearman": {"calculate": False},
532
+ "kendall": {"calculate": False},
533
+ "cramers": {"calculate": False},
534
+ },
535
+ "correlation_table": True,
536
+ }
537
+
538
+ @staticmethod
539
+ def get_arg_groups(key: str) -> dict:
540
+ kwargs = Config.arg_groups[key]
541
+ shorthand_args, _ = Config.shorthands(kwargs, split=False)
542
+ return shorthand_args
543
+
544
+ @staticmethod
545
+ def shorthands(kwargs: dict, split: bool = True) -> tuple[dict, dict]:
546
+ shorthand_args = {}
547
+ if not split:
548
+ shorthand_args = kwargs
549
+ for key, value in list(kwargs.items()):
550
+ if value is None and key in Config._shorthands:
551
+ shorthand_args[key] = Config._shorthands[key]
552
+ if split:
553
+ del kwargs[key]
554
+
555
+ if split:
556
+ return shorthand_args, kwargs
557
+ else:
558
+ return shorthand_args, {}