@@ -73,6 +73,7 @@ def __init__(
7373 sortby : Optional [str ] = None ,
7474 sensitive : bool = False ,
7575 explorative : bool = False ,
76+ excluded_fields : list [str ] | None = None ,
7677 sample : Optional [dict ] = None ,
7778 config_file : Optional [Union [Path , str ]] = None ,
7879 lazy : bool = True ,
@@ -97,6 +98,7 @@ def __init__(
9798 Only available for pd.DataFrame
9899 sort_by: ignored if ts_mode=False. Order the dataset by a provided column.
99100 sensitive: hides the values for categorical and text variables for report privacy
101+ excluded_fields: excludes selected fields from JSON generation
100102 config_file: a config file (.yml), mutually exclusive with `minimal`
101103 lazy: compute when needed
102104 sample: optional dict(name="Sample title", caption="Caption", data=pd.DataFrame())
@@ -110,6 +112,8 @@ def __init__(
110112
111113 self ._df_type = type (df )
112114
115+ self .excluded_fields = excluded_fields
116+
113117 if config_file or minimal :
114118 if not config_file :
115119 config_file = get_config ("config_minimal.yaml" )
@@ -453,7 +457,11 @@ def encode_it(o: Any) -> Any:
453457 if is_dataclass (o ):
454458 o = asdict (o )
455459 if isinstance (o , dict ):
456- return {encode_it (k ): encode_it (v ) for k , v in o .items ()}
460+ return {
461+ encode_it (k ): encode_it (v )
462+ for k , v in o .items ()
463+ if (self .excluded_fields is None or k not in self .excluded_fields )
464+ }
457465 else :
458466 if isinstance (o , (bool , int , float , str )):
459467 return o
@@ -502,6 +510,22 @@ def to_json(self) -> str:
502510
503511 Returns:
504512 JSON string
513+
514+ To disable fields for output, pass a list with
515+ of fields to exclude.
516+ Example:
517+ from data_profiling import ProfileReport
518+ import pandas as pd
519+
520+ df = pd.DataFrame(np.random.rand(7, 3), columns=["a", "b", "c"])
521+ fields = ["value_counts_without_nan",
522+ "value_counts_index_sorted", "n_var"]
523+ profile = ProfileReport(
524+ df, title="Data Profiling Report",
525+ excluded_fields=fields
526+ )
527+ report_json = profile.to_json()
528+
505529 """
506530
507531 return self .json
0 commit comments