fg-data-profiling 4.19.0__py2.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 (238) hide show
  1. data_profiling/__init__.py +34 -0
  2. data_profiling/compare_reports.py +359 -0
  3. data_profiling/config.py +496 -0
  4. data_profiling/config_default.yaml +223 -0
  5. data_profiling/config_minimal.yaml +222 -0
  6. data_profiling/controller/__init__.py +1 -0
  7. data_profiling/controller/console.py +125 -0
  8. data_profiling/controller/pandas_decorator.py +21 -0
  9. data_profiling/expectations_report.py +117 -0
  10. data_profiling/model/__init__.py +4 -0
  11. data_profiling/model/alerts.py +780 -0
  12. data_profiling/model/correlations.py +163 -0
  13. data_profiling/model/dataframe.py +35 -0
  14. data_profiling/model/describe.py +210 -0
  15. data_profiling/model/description.py +108 -0
  16. data_profiling/model/duplicates.py +14 -0
  17. data_profiling/model/expectation_algorithms.py +112 -0
  18. data_profiling/model/handler.py +81 -0
  19. data_profiling/model/missing.py +146 -0
  20. data_profiling/model/pairwise.py +33 -0
  21. data_profiling/model/pandas/__init__.py +55 -0
  22. data_profiling/model/pandas/correlations_pandas.py +207 -0
  23. data_profiling/model/pandas/dataframe_pandas.py +26 -0
  24. data_profiling/model/pandas/describe_boolean_pandas.py +43 -0
  25. data_profiling/model/pandas/describe_categorical_pandas.py +274 -0
  26. data_profiling/model/pandas/describe_counts_pandas.py +63 -0
  27. data_profiling/model/pandas/describe_date_pandas.py +77 -0
  28. data_profiling/model/pandas/describe_file_pandas.py +56 -0
  29. data_profiling/model/pandas/describe_generic_pandas.py +36 -0
  30. data_profiling/model/pandas/describe_image_pandas.py +255 -0
  31. data_profiling/model/pandas/describe_numeric_pandas.py +175 -0
  32. data_profiling/model/pandas/describe_path_pandas.py +63 -0
  33. data_profiling/model/pandas/describe_supported_pandas.py +41 -0
  34. data_profiling/model/pandas/describe_text_pandas.py +62 -0
  35. data_profiling/model/pandas/describe_timeseries_pandas.py +222 -0
  36. data_profiling/model/pandas/describe_url_pandas.py +57 -0
  37. data_profiling/model/pandas/discretize_pandas.py +81 -0
  38. data_profiling/model/pandas/duplicates_pandas.py +56 -0
  39. data_profiling/model/pandas/imbalance_pandas.py +35 -0
  40. data_profiling/model/pandas/missing_pandas.py +42 -0
  41. data_profiling/model/pandas/sample_pandas.py +38 -0
  42. data_profiling/model/pandas/summary_pandas.py +101 -0
  43. data_profiling/model/pandas/table_pandas.py +56 -0
  44. data_profiling/model/pandas/timeseries_index_pandas.py +33 -0
  45. data_profiling/model/pandas/utils_pandas.py +27 -0
  46. data_profiling/model/sample.py +37 -0
  47. data_profiling/model/spark/__init__.py +48 -0
  48. data_profiling/model/spark/correlations_spark.py +152 -0
  49. data_profiling/model/spark/dataframe_spark.py +34 -0
  50. data_profiling/model/spark/describe_boolean_spark.py +27 -0
  51. data_profiling/model/spark/describe_categorical_spark.py +28 -0
  52. data_profiling/model/spark/describe_counts_spark.py +105 -0
  53. data_profiling/model/spark/describe_date_spark.py +51 -0
  54. data_profiling/model/spark/describe_generic_spark.py +30 -0
  55. data_profiling/model/spark/describe_numeric_spark.py +155 -0
  56. data_profiling/model/spark/describe_supported_spark.py +33 -0
  57. data_profiling/model/spark/describe_text_spark.py +25 -0
  58. data_profiling/model/spark/duplicates_spark.py +54 -0
  59. data_profiling/model/spark/missing_spark.py +96 -0
  60. data_profiling/model/spark/sample_spark.py +43 -0
  61. data_profiling/model/spark/summary_spark.py +95 -0
  62. data_profiling/model/spark/table_spark.py +58 -0
  63. data_profiling/model/spark/timeseries_index_spark.py +12 -0
  64. data_profiling/model/summarizer.py +207 -0
  65. data_profiling/model/summary.py +66 -0
  66. data_profiling/model/summary_algorithms.py +276 -0
  67. data_profiling/model/table.py +10 -0
  68. data_profiling/model/timeseries_index.py +16 -0
  69. data_profiling/model/typeset.py +365 -0
  70. data_profiling/model/typeset_relations.py +143 -0
  71. data_profiling/profile_report.py +573 -0
  72. data_profiling/report/__init__.py +4 -0
  73. data_profiling/report/formatters.py +346 -0
  74. data_profiling/report/presentation/__init__.py +1 -0
  75. data_profiling/report/presentation/core/__init__.py +39 -0
  76. data_profiling/report/presentation/core/alerts.py +18 -0
  77. data_profiling/report/presentation/core/collapse.py +24 -0
  78. data_profiling/report/presentation/core/container.py +50 -0
  79. data_profiling/report/presentation/core/correlation_table.py +21 -0
  80. data_profiling/report/presentation/core/dropdown.py +44 -0
  81. data_profiling/report/presentation/core/duplicate.py +16 -0
  82. data_profiling/report/presentation/core/frequency_table.py +14 -0
  83. data_profiling/report/presentation/core/frequency_table_small.py +16 -0
  84. data_profiling/report/presentation/core/html.py +14 -0
  85. data_profiling/report/presentation/core/image.py +34 -0
  86. data_profiling/report/presentation/core/item_renderer.py +17 -0
  87. data_profiling/report/presentation/core/renderable.py +42 -0
  88. data_profiling/report/presentation/core/root.py +35 -0
  89. data_profiling/report/presentation/core/sample.py +20 -0
  90. data_profiling/report/presentation/core/scores.py +32 -0
  91. data_profiling/report/presentation/core/table.py +26 -0
  92. data_profiling/report/presentation/core/toggle_button.py +14 -0
  93. data_profiling/report/presentation/core/variable.py +40 -0
  94. data_profiling/report/presentation/core/variable_info.py +36 -0
  95. data_profiling/report/presentation/flavours/__init__.py +9 -0
  96. data_profiling/report/presentation/flavours/flavour_html.py +64 -0
  97. data_profiling/report/presentation/flavours/flavour_widget.py +61 -0
  98. data_profiling/report/presentation/flavours/flavours.py +43 -0
  99. data_profiling/report/presentation/flavours/html/__init__.py +47 -0
  100. data_profiling/report/presentation/flavours/html/alerts.py +10 -0
  101. data_profiling/report/presentation/flavours/html/collapse.py +7 -0
  102. data_profiling/report/presentation/flavours/html/container.py +58 -0
  103. data_profiling/report/presentation/flavours/html/correlation_table.py +13 -0
  104. data_profiling/report/presentation/flavours/html/dropdown.py +7 -0
  105. data_profiling/report/presentation/flavours/html/duplicate.py +24 -0
  106. data_profiling/report/presentation/flavours/html/frequency_table.py +20 -0
  107. data_profiling/report/presentation/flavours/html/frequency_table_small.py +15 -0
  108. data_profiling/report/presentation/flavours/html/html.py +6 -0
  109. data_profiling/report/presentation/flavours/html/image.py +7 -0
  110. data_profiling/report/presentation/flavours/html/root.py +14 -0
  111. data_profiling/report/presentation/flavours/html/sample.py +12 -0
  112. data_profiling/report/presentation/flavours/html/scores.py +11 -0
  113. data_profiling/report/presentation/flavours/html/table.py +7 -0
  114. data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant.html +1 -0
  115. data_profiling/report/presentation/flavours/html/templates/alerts/alert_constant_length.html +1 -0
  116. data_profiling/report/presentation/flavours/html/templates/alerts/alert_dirty_category.html +1 -0
  117. data_profiling/report/presentation/flavours/html/templates/alerts/alert_duplicates.html +1 -0
  118. data_profiling/report/presentation/flavours/html/templates/alerts/alert_empty.html +1 -0
  119. data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_cardinality.html +1 -0
  120. data_profiling/report/presentation/flavours/html/templates/alerts/alert_high_correlation.html +4 -0
  121. data_profiling/report/presentation/flavours/html/templates/alerts/alert_imbalance.html +1 -0
  122. data_profiling/report/presentation/flavours/html/templates/alerts/alert_infinite.html +1 -0
  123. data_profiling/report/presentation/flavours/html/templates/alerts/alert_missing.html +1 -0
  124. data_profiling/report/presentation/flavours/html/templates/alerts/alert_near_duplicates.html +1 -0
  125. data_profiling/report/presentation/flavours/html/templates/alerts/alert_non_stationary.html +1 -0
  126. data_profiling/report/presentation/flavours/html/templates/alerts/alert_seasonal.html +1 -0
  127. data_profiling/report/presentation/flavours/html/templates/alerts/alert_skewed.html +1 -0
  128. data_profiling/report/presentation/flavours/html/templates/alerts/alert_truncated.html +1 -0
  129. data_profiling/report/presentation/flavours/html/templates/alerts/alert_type_date.html +1 -0
  130. data_profiling/report/presentation/flavours/html/templates/alerts/alert_uniform.html +1 -0
  131. data_profiling/report/presentation/flavours/html/templates/alerts/alert_unique.html +1 -0
  132. data_profiling/report/presentation/flavours/html/templates/alerts/alert_unsupported.html +1 -0
  133. data_profiling/report/presentation/flavours/html/templates/alerts/alert_zeros.html +1 -0
  134. data_profiling/report/presentation/flavours/html/templates/alerts.html +47 -0
  135. data_profiling/report/presentation/flavours/html/templates/collapse.html +11 -0
  136. data_profiling/report/presentation/flavours/html/templates/correlation_table.html +5 -0
  137. data_profiling/report/presentation/flavours/html/templates/diagram.html +11 -0
  138. data_profiling/report/presentation/flavours/html/templates/dropdown.html +16 -0
  139. data_profiling/report/presentation/flavours/html/templates/duplicate.html +5 -0
  140. data_profiling/report/presentation/flavours/html/templates/frequency_table.html +45 -0
  141. data_profiling/report/presentation/flavours/html/templates/frequency_table_small.html +34 -0
  142. data_profiling/report/presentation/flavours/html/templates/report.html +26 -0
  143. data_profiling/report/presentation/flavours/html/templates/sample.html +10 -0
  144. data_profiling/report/presentation/flavours/html/templates/scores.html +78 -0
  145. data_profiling/report/presentation/flavours/html/templates/sequence/batch_grid.html +16 -0
  146. data_profiling/report/presentation/flavours/html/templates/sequence/grid.html +18 -0
  147. data_profiling/report/presentation/flavours/html/templates/sequence/list.html +7 -0
  148. data_profiling/report/presentation/flavours/html/templates/sequence/named_list.html +8 -0
  149. data_profiling/report/presentation/flavours/html/templates/sequence/overview_tabs.html +30 -0
  150. data_profiling/report/presentation/flavours/html/templates/sequence/scores.html +3 -0
  151. data_profiling/report/presentation/flavours/html/templates/sequence/sections.html +13 -0
  152. data_profiling/report/presentation/flavours/html/templates/sequence/select.html +40 -0
  153. data_profiling/report/presentation/flavours/html/templates/sequence/tabs.html +30 -0
  154. data_profiling/report/presentation/flavours/html/templates/table.html +38 -0
  155. data_profiling/report/presentation/flavours/html/templates/toggle_button.html +18 -0
  156. data_profiling/report/presentation/flavours/html/templates/variable.html +7 -0
  157. data_profiling/report/presentation/flavours/html/templates/variable_info.html +49 -0
  158. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.bundle.min.js +7 -0
  159. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/bootstrap.min.css +6 -0
  160. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/cosmo.bootstrap.min.css +12 -0
  161. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/flatly.bootstrap.min.css +12 -0
  162. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/script.js +52 -0
  163. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/simplex.bootstrap.min.css +12 -0
  164. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/style.css +253 -0
  165. data_profiling/report/presentation/flavours/html/templates/wrapper/assets/united.bootstrap.min.css +12 -0
  166. data_profiling/report/presentation/flavours/html/templates/wrapper/footer.html +7 -0
  167. data_profiling/report/presentation/flavours/html/templates/wrapper/javascript.html +18 -0
  168. data_profiling/report/presentation/flavours/html/templates/wrapper/navigation.html +36 -0
  169. data_profiling/report/presentation/flavours/html/templates/wrapper/style.html +53 -0
  170. data_profiling/report/presentation/flavours/html/templates.py +76 -0
  171. data_profiling/report/presentation/flavours/html/toggle_button.py +7 -0
  172. data_profiling/report/presentation/flavours/html/variable.py +7 -0
  173. data_profiling/report/presentation/flavours/html/variable_info.py +7 -0
  174. data_profiling/report/presentation/flavours/widget/__init__.py +49 -0
  175. data_profiling/report/presentation/flavours/widget/alerts.py +45 -0
  176. data_profiling/report/presentation/flavours/widget/collapse.py +43 -0
  177. data_profiling/report/presentation/flavours/widget/container.py +121 -0
  178. data_profiling/report/presentation/flavours/widget/correlation_table.py +14 -0
  179. data_profiling/report/presentation/flavours/widget/dropdown.py +31 -0
  180. data_profiling/report/presentation/flavours/widget/duplicate.py +14 -0
  181. data_profiling/report/presentation/flavours/widget/frequency_table.py +57 -0
  182. data_profiling/report/presentation/flavours/widget/frequency_table_small.py +66 -0
  183. data_profiling/report/presentation/flavours/widget/html.py +11 -0
  184. data_profiling/report/presentation/flavours/widget/image.py +26 -0
  185. data_profiling/report/presentation/flavours/widget/notebook.py +81 -0
  186. data_profiling/report/presentation/flavours/widget/root.py +10 -0
  187. data_profiling/report/presentation/flavours/widget/sample.py +14 -0
  188. data_profiling/report/presentation/flavours/widget/table.py +30 -0
  189. data_profiling/report/presentation/flavours/widget/toggle_button.py +17 -0
  190. data_profiling/report/presentation/flavours/widget/variable.py +12 -0
  191. data_profiling/report/presentation/flavours/widget/variable_info.py +11 -0
  192. data_profiling/report/presentation/frequency_table_utils.py +141 -0
  193. data_profiling/report/structure/__init__.py +1 -0
  194. data_profiling/report/structure/correlations.py +123 -0
  195. data_profiling/report/structure/overview.py +376 -0
  196. data_profiling/report/structure/report.py +457 -0
  197. data_profiling/report/structure/variables/__init__.py +35 -0
  198. data_profiling/report/structure/variables/render_boolean.py +132 -0
  199. data_profiling/report/structure/variables/render_categorical.py +566 -0
  200. data_profiling/report/structure/variables/render_common.py +31 -0
  201. data_profiling/report/structure/variables/render_complex.py +102 -0
  202. data_profiling/report/structure/variables/render_count.py +172 -0
  203. data_profiling/report/structure/variables/render_date.py +143 -0
  204. data_profiling/report/structure/variables/render_file.py +70 -0
  205. data_profiling/report/structure/variables/render_generic.py +45 -0
  206. data_profiling/report/structure/variables/render_image.py +204 -0
  207. data_profiling/report/structure/variables/render_path.py +134 -0
  208. data_profiling/report/structure/variables/render_real.py +314 -0
  209. data_profiling/report/structure/variables/render_text.py +189 -0
  210. data_profiling/report/structure/variables/render_timeseries.py +371 -0
  211. data_profiling/report/structure/variables/render_url.py +132 -0
  212. data_profiling/report/utils.py +34 -0
  213. data_profiling/serialize_report.py +143 -0
  214. data_profiling/utils/__init__.py +1 -0
  215. data_profiling/utils/backend.py +9 -0
  216. data_profiling/utils/cache.py +59 -0
  217. data_profiling/utils/common.py +142 -0
  218. data_profiling/utils/compat.py +31 -0
  219. data_profiling/utils/dataframe.py +238 -0
  220. data_profiling/utils/logger.py +53 -0
  221. data_profiling/utils/notebook.py +8 -0
  222. data_profiling/utils/paths.py +45 -0
  223. data_profiling/utils/progress_bar.py +15 -0
  224. data_profiling/utils/styles.py +22 -0
  225. data_profiling/utils/versions.py +19 -0
  226. data_profiling/version.py +1 -0
  227. data_profiling/visualisation/__init__.py +1 -0
  228. data_profiling/visualisation/context.py +87 -0
  229. data_profiling/visualisation/missing.py +138 -0
  230. data_profiling/visualisation/plot.py +1158 -0
  231. data_profiling/visualisation/utils.py +113 -0
  232. fg_data_profiling-4.19.0.dist-info/METADATA +362 -0
  233. fg_data_profiling-4.19.0.dist-info/RECORD +238 -0
  234. fg_data_profiling-4.19.0.dist-info/WHEEL +6 -0
  235. fg_data_profiling-4.19.0.dist-info/entry_points.txt +3 -0
  236. fg_data_profiling-4.19.0.dist-info/licenses/LICENSE +21 -0
  237. fg_data_profiling-4.19.0.dist-info/top_level.txt +2 -0
  238. ydata_profiling/__init__.py +43 -0
@@ -0,0 +1,222 @@
1
+ # Title of the document
2
+ title: YData Profiling Report
3
+
4
+ # Metadata
5
+ dataset:
6
+ description: ""
7
+ creator: ""
8
+ author: ""
9
+ copyright_holder: ""
10
+ copyright_year: ""
11
+ url: ""
12
+
13
+ variables:
14
+ descriptions: {}
15
+
16
+ # infer dtypes
17
+ infer_dtypes: false
18
+
19
+ # Show the description at each variable (in addition to the overview tab)
20
+ show_variable_description: true
21
+
22
+ # Number of workers (0=multiprocessing.cpu_count())
23
+ pool_size: 0
24
+
25
+ # Show the progress bar
26
+ progress_bar: true
27
+
28
+ # Per variable type description settings
29
+ vars:
30
+ num:
31
+ quantiles:
32
+ - 0.05
33
+ - 0.25
34
+ - 0.5
35
+ - 0.75
36
+ - 0.95
37
+ skewness_threshold: 20
38
+ low_categorical_threshold: 5
39
+ # Set to zero to disable
40
+ chi_squared_threshold: 0
41
+ cat:
42
+ length: false
43
+ characters: false
44
+ words: false
45
+ cardinality_threshold: 50
46
+ n_obs: 5
47
+ # Set to zero to disable
48
+ chi_squared_threshold: 0
49
+ coerce_str_to_date: false
50
+ redact: false
51
+ histogram_largest: 10
52
+ stop_words: []
53
+ bool:
54
+ n_obs: 3
55
+ # string to boolean mapping dict
56
+ mappings:
57
+ t: true
58
+ f: false
59
+ yes: true
60
+ no: false
61
+ y: true
62
+ n: false
63
+ "true": true
64
+ "false": false
65
+ path:
66
+ active: false
67
+ file:
68
+ active: false
69
+ image:
70
+ active: false
71
+ exif: false
72
+ hash: false
73
+ url:
74
+ active: false
75
+ timeseries:
76
+ active: false
77
+ autocorrelation: 0.7
78
+ lags:
79
+ - 1
80
+ - 7
81
+ - 12
82
+ - 24
83
+ - 30
84
+ significance: 0.05
85
+ pacf_acf_lag: 100
86
+
87
+ # Sort the variables. Possible values: "ascending", "descending" or null (leaves original sorting)
88
+ sort: null
89
+
90
+ # which diagrams to show
91
+ missing_diagrams:
92
+ bar: false
93
+ matrix: false
94
+ heatmap: false
95
+
96
+ correlations:
97
+ pearson:
98
+ calculate: false
99
+ warn_high_correlations: true
100
+ threshold: 0.9
101
+ spearman:
102
+ calculate: false
103
+ warn_high_correlations: false
104
+ threshold: 0.9
105
+ kendall:
106
+ calculate: false
107
+ warn_high_correlations: false
108
+ threshold: 0.9
109
+ phi_k:
110
+ calculate: false
111
+ warn_high_correlations: false
112
+ threshold: 0.9
113
+ cramers:
114
+ calculate: false
115
+ warn_high_correlations: true
116
+ threshold: 0.9
117
+ auto:
118
+ calculate: false
119
+ warn_high_correlations: true
120
+ threshold: 0.9
121
+
122
+ # Bivariate / Pairwise relations
123
+ interactions:
124
+ targets: []
125
+ continuous: false
126
+
127
+ # For categorical
128
+ categorical_maximum_correlation_distinct: 100
129
+
130
+ report:
131
+ precision: 10
132
+
133
+ # Plot-specific settings
134
+ plot:
135
+ # Image format (svg or png)
136
+ image_format: svg
137
+ dpi: 800
138
+
139
+ scatter_threshold: 1000
140
+
141
+ correlation:
142
+ cmap: RdBu
143
+ bad: "#000000"
144
+
145
+ missing:
146
+ cmap: RdBu
147
+ # Force labels when there are > 50 variables
148
+ force_labels: true
149
+
150
+ cat_frequency:
151
+ show: true # if false, the category frequency plot is turned off
152
+ type: bar # options: 'bar', 'pie'
153
+ max_unique: 0
154
+ colors: null # use null for default or give a list of matplotlib recognized strings
155
+
156
+ histogram:
157
+ x_axis_labels: true
158
+
159
+ # Number of bins (set to 0 to automatically detect the bin size)
160
+ bins: 50
161
+
162
+ # Maximum number of bins (when bins=0)
163
+ max_bins: 250
164
+
165
+ font_path: null
166
+
167
+ # The number of observations to show
168
+ n_obs_unique: 5
169
+ n_extreme_obs: 5
170
+ n_freq_table_max: 10
171
+
172
+ # Use `deep` flag for memory_usage
173
+ memory_deep: false
174
+
175
+ # Configuration related to the duplicates
176
+ duplicates:
177
+ head: 0
178
+ key: "# duplicates"
179
+
180
+ # Configuration related to the samples area
181
+ samples:
182
+ head: 0
183
+ tail: 0
184
+ random: 0
185
+
186
+ # Configuration related to the rejection of variables
187
+ reject_variables: true
188
+
189
+ # When in a Jupyter notebook
190
+ notebook:
191
+ iframe:
192
+ height: 800px
193
+ width: 100%
194
+ # or 'src'
195
+ attribute: srcdoc
196
+
197
+ html:
198
+ # Minify the html
199
+ minify_html: true
200
+
201
+ # Offline support
202
+ use_local_assets: true
203
+
204
+ # If true, single file, else directory with assets
205
+ inline: true
206
+
207
+ # Show navbar
208
+ navbar_show: true
209
+
210
+ # Assets prefix if inline = true
211
+ assets_prefix: null
212
+
213
+ # Styling options for the HTML report
214
+ style:
215
+ theme: null
216
+ logo: ""
217
+ primary_colors:
218
+ - "#0d6efd"
219
+ - "#dc3545"
220
+ - "#198754"
221
+
222
+ full_width: false
@@ -0,0 +1 @@
1
+ """The controller module handles all user interaction with the package (console, jupyter, etc.)."""
@@ -0,0 +1,125 @@
1
+ """This file add the console interface to the package."""
2
+ import argparse
3
+ from pathlib import Path
4
+ from typing import Any, List, Optional
5
+
6
+ from data_profiling.__init__ import ProfileReport, __version__
7
+ from data_profiling.utils.dataframe import read_pandas
8
+
9
+
10
+ def parse_args(args: Optional[List[Any]] = None) -> argparse.Namespace:
11
+ """Parse the command line arguments for the `data_profiling` binary.
12
+
13
+ Args:
14
+ args: List of input arguments. (Default value=None).
15
+
16
+ Returns:
17
+ Namespace with parsed arguments.
18
+
19
+ """
20
+ parser = argparse.ArgumentParser(
21
+ description="Profile the variables in a CSV file and generate a HTML report."
22
+ )
23
+
24
+ # Version
25
+ parser.add_argument(
26
+ "--version", action="version", version=f"%(prog)s {__version__}"
27
+ )
28
+
29
+ # Console specific
30
+ parser.add_argument(
31
+ "-s",
32
+ "--silent",
33
+ help="Only generate but do not open report",
34
+ action="store_true",
35
+ )
36
+
37
+ parser.add_argument(
38
+ "-m",
39
+ "--minimal",
40
+ help="Minimal configuration for big data sets",
41
+ action="store_true",
42
+ )
43
+
44
+ parser.add_argument(
45
+ "-e",
46
+ "--explorative",
47
+ help="Explorative configuration featuring unicode, file and image analysis",
48
+ action="store_true",
49
+ )
50
+
51
+ # Config
52
+ parser.add_argument(
53
+ "--pool_size", type=int, default=0, help="Number of CPU cores to use"
54
+ )
55
+ parser.add_argument(
56
+ "--title",
57
+ type=str,
58
+ default="YData Profiling Report",
59
+ help="Title for the report",
60
+ )
61
+
62
+ parser.add_argument(
63
+ "--infer_dtypes",
64
+ default=False,
65
+ action="store_true",
66
+ help="To infer dtypes of the dataframe",
67
+ )
68
+
69
+ parser.add_argument(
70
+ "--no-infer_dtypes",
71
+ dest="infer_dtypes",
72
+ action="store_false",
73
+ help="To read dtypes as read by pandas",
74
+ )
75
+
76
+ parser.add_argument(
77
+ "--config_file",
78
+ type=str,
79
+ default=None,
80
+ help="Specify a yaml config file. Have a look at the 'config_default.yaml' as a starting point.",
81
+ )
82
+
83
+ parser.add_argument(
84
+ "input_file",
85
+ type=str,
86
+ help="CSV file (or other file type supported by pandas) to profile",
87
+ )
88
+ parser.add_argument(
89
+ "output_file",
90
+ type=str,
91
+ nargs="?",
92
+ help="Output report file. If empty, replaces the input_file's extension with .html and uses that.",
93
+ default=None,
94
+ )
95
+
96
+ return parser.parse_args(args)
97
+
98
+
99
+ def main(args: Optional[List[Any]] = None) -> None:
100
+ """Run the `data_profiling` package.
101
+
102
+ Args:
103
+ args: Arguments for the programme (Default value=None).
104
+ """
105
+
106
+ # Parse the arguments
107
+ parsed_args = parse_args(args)
108
+ kwargs = vars(parsed_args)
109
+
110
+ input_file = Path(kwargs.pop("input_file"))
111
+ output_file = kwargs.pop("output_file")
112
+ if output_file is None:
113
+ output_file = str(input_file.with_suffix(".html"))
114
+
115
+ silent = kwargs.pop("silent")
116
+
117
+ # read the DataFrame
118
+ df = read_pandas(input_file)
119
+
120
+ # Generate the profiling report
121
+ p = ProfileReport(
122
+ df,
123
+ **kwargs,
124
+ )
125
+ p.to_file(Path(output_file), silent=silent)
@@ -0,0 +1,21 @@
1
+ """This file add the decorator on the DataFrame object."""
2
+ from pandas import DataFrame
3
+
4
+ from data_profiling.profile_report import ProfileReport
5
+
6
+
7
+ def profile_report(df: DataFrame, **kwargs) -> ProfileReport:
8
+ """Profile a DataFrame.
9
+
10
+ Args:
11
+ df: The DataFrame to profile.
12
+ **kwargs: Optional arguments for the ProfileReport object.
13
+
14
+ Returns:
15
+ A ProfileReport of the DataFrame.
16
+ """
17
+ p = ProfileReport(df, **kwargs)
18
+ return p
19
+
20
+
21
+ DataFrame.profile_report = profile_report
@@ -0,0 +1,117 @@
1
+ from typing import Any, Optional
2
+
3
+ import pandas as pd
4
+ from visions import VisionsTypeset
5
+
6
+ from data_profiling.config import Settings
7
+ from data_profiling.model import BaseDescription, expectation_algorithms
8
+ from data_profiling.model.handler import Handler
9
+ from data_profiling.utils.dataframe import slugify
10
+
11
+
12
+ class ExpectationHandler(Handler):
13
+ """Default handler"""
14
+
15
+ def __init__(self, typeset: VisionsTypeset, *args, **kwargs):
16
+ mapping = {
17
+ "Unsupported": [expectation_algorithms.generic_expectations],
18
+ "Text": [expectation_algorithms.categorical_expectations],
19
+ "Categorical": [expectation_algorithms.categorical_expectations],
20
+ "Boolean": [expectation_algorithms.categorical_expectations],
21
+ "Numeric": [expectation_algorithms.numeric_expectations],
22
+ "URL": [expectation_algorithms.url_expectations],
23
+ "File": [expectation_algorithms.file_expectations],
24
+ "Path": [expectation_algorithms.path_expectations],
25
+ "DateTime": [expectation_algorithms.datetime_expectations],
26
+ "Image": [expectation_algorithms.image_expectations],
27
+ }
28
+ super().__init__(mapping, typeset, *args, **kwargs)
29
+
30
+
31
+ class ExpectationsReport:
32
+ config: Settings
33
+ df: Optional[pd.DataFrame] = None
34
+
35
+ @property
36
+ def typeset(self) -> Optional[VisionsTypeset]:
37
+ return None
38
+
39
+ def to_expectation_suite(
40
+ self,
41
+ suite_name: Optional[str] = None,
42
+ data_context: Optional[Any] = None,
43
+ save_suite: bool = True,
44
+ run_validation: bool = True,
45
+ build_data_docs: bool = True,
46
+ handler: Optional[Handler] = None,
47
+ ) -> Any:
48
+ """
49
+ All parameters default to True to make it easier to access the full functionality of Great Expectations out of
50
+ the box.
51
+ Args:
52
+ suite_name: The name of your expectation suite
53
+ data_context: A user-specified data context
54
+ save_suite: Boolean to determine whether to save the suite to .json as part of the method
55
+ run_validation: Boolean to determine whether to run validation as part of the method
56
+ build_data_docs: Boolean to determine whether to build data docs, save the .html file, and open data docs in
57
+ your browser
58
+ handler: The handler to use for building expectation
59
+
60
+ Returns:
61
+ An ExpectationSuite
62
+ """
63
+ try:
64
+ import great_expectations as ge
65
+ except ImportError as ex:
66
+ raise ImportError(
67
+ "Please install great expectations before using the expectation functionality"
68
+ ) from ex
69
+
70
+ # Use report title if suite is empty
71
+ if suite_name is None:
72
+ suite_name = slugify(self.config.title)
73
+
74
+ # Use the default handler if none
75
+ if handler is None:
76
+ handler = ExpectationHandler(self.typeset)
77
+
78
+ # Obtain the ge context and create the expectation suite
79
+ if not data_context:
80
+ data_context = ge.data_context.DataContext()
81
+
82
+ suite = data_context.add_expectation_suite(suite_name)
83
+
84
+ # Instantiate an in-memory pandas dataset
85
+ batch = ge.dataset.PandasDataset(self.df, expectation_suite=suite)
86
+
87
+ # Obtain the profiling summary
88
+ summary: BaseDescription = self.get_description() # type: ignore
89
+
90
+ # Dispatch to expectations per semantic variable type
91
+ for name, variable_summary in summary.variables.items():
92
+ handler.handle(variable_summary["type"], name, variable_summary, batch)
93
+
94
+ # We don't actually update the suite object on the batch in place, so need
95
+ # to get the populated suite from the batch
96
+ suite = batch.get_expectation_suite()
97
+
98
+ validation_result_identifier = None
99
+ if run_validation:
100
+ batch = ge.dataset.PandasDataset(self.df, expectation_suite=suite)
101
+
102
+ results = data_context.run_validation_operator(
103
+ "action_list_operator", assets_to_validate=[batch]
104
+ )
105
+ validation_result_identifier = results.list_validation_result_identifiers()[
106
+ 0
107
+ ]
108
+
109
+ # Write expectations and open data docs
110
+ if save_suite or build_data_docs:
111
+ data_context.save_expectation_suite(suite)
112
+
113
+ if build_data_docs:
114
+ data_context.build_data_docs()
115
+ data_context.open_data_docs(validation_result_identifier)
116
+
117
+ return batch.get_expectation_suite()
@@ -0,0 +1,4 @@
1
+ """The model module handles all logic/calculations, e.g. calculate statistics, testing for special conditions."""
2
+ from data_profiling.model.description import BaseAnalysis, BaseDescription
3
+
4
+ __all__ = ["BaseAnalysis", "BaseDescription"]