You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Profile report HTML cannot be generated for dataframes with very large integers. It seems like an overflow issue. Would it be possible to fix this? Even if a report for this series cannot be generated, it would be great if pandas-profiling could at least handle it gracefully so that the code does not crash. For example, if one of the series in a dataframe would encounter this issue, would it be possible to omit it from the report, and only report on the other series?
To Reproduce
import pandas as pd
from pandas_profiling import ProfileReport
df = pd.DataFrame({"col": pd.Series([716277643516076032 + i for i in range(100)])})
df_profile = ProfileReport(df)
profile_html = df_profile.to_html()
Full stack trace
IndexError: index 10 is out of bounds for axis 0 with size 9
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<command-1661028028735696> in <module>
4 df = pd.DataFrame({"col": pd.Series([716277643516076032 + i for i in range(100)])})
5 df_profile = ProfileReport(df)
----> 6 profile_html = df_profile.to_html()
7 profile_html
/databricks/python/lib/python3.8/site-packages/pandas_profiling/profile_report.py in to_html(self)
366
367 """
--> 368 return self.html
369
370 def to_json(self) -> str:
/databricks/python/lib/python3.8/site-packages/pandas_profiling/profile_report.py in html(self)
183 def html(self) -> str:
184 if self._html is None:
--> 185 self._html = self._render_html()
186 return self._html
187
/databricks/python/lib/python3.8/site-packages/pandas_profiling/profile_report.py in _render_html(self)
285 from pandas_profiling.report.presentation.flavours import HTMLReport
286
--> 287 report = self.report
288
289 with tqdm(
/databricks/python/lib/python3.8/site-packages/pandas_profiling/profile_report.py in report(self)
177 def report(self) -> Root:
178 if self._report is None:
--> 179 self._report = get_report_structure(self.config, self.description_set)
180 return self._report
181
/databricks/python/lib/python3.8/site-packages/pandas_profiling/profile_report.py in description_set(self)
159 def description_set(self) -> Dict[str, Any]:
160 if self._description_set is None:
--> 161 self._description_set = describe_df(
162 self.config,
163 self.df,
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/describe.py in describe(config, df, summarizer, typeset, sample)
69 # Variable-specific
70 pbar.total += len(df.columns)
---> 71 series_description = get_series_descriptions(
72 config, df, summarizer, typeset, pbar
73 )
/databricks/python/lib/python3.8/site-packages/multimethod/__init__.py in __call__(self, *args, **kwargs)
301 func = self[tuple(func(arg) for func, arg in zip(self.type_checkers, args))]
302 try:
--> 303 return func(*args, **kwargs)
304 except TypeError as ex:
305 raise DispatchError(f"Function {func.__code__}") from ex
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/pandas/summary_pandas.py in pandas_get_series_descriptions(config, df, summarizer, typeset, pbar)
90 # TODO: use `Pool` for Linux-based systems
91 with multiprocessing.pool.ThreadPool(pool_size) as executor:
---> 92 for i, (column, description) in enumerate(
93 executor.imap_unordered(multiprocess_1d, args)
94 ):
/usr/lib/python3.8/multiprocessing/pool.py in next(self, timeout)
866 if success:
867 return value
--> 868 raise value
869
870 __next__ = next # XXX
/usr/lib/python3.8/multiprocessing/pool.py in worker(inqueue, outqueue, initializer, initargs, maxtasks, wrap_exception)
123 job, i, func, args, kwds = task
124 try:
--> 125 result = (True, func(*args, **kwds))
126 except Exception as e:
127 if wrap_exception and func is not _helper_reraises_exception:
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/pandas/summary_pandas.py in multiprocess_1d(args)
70 """
71 column, series = args
---> 72 return column, describe_1d(config, series, summarizer, typeset)
73
74 pool_size = config.pool_size
/databricks/python/lib/python3.8/site-packages/multimethod/__init__.py in __call__(self, *args, **kwargs)
301 func = self[tuple(func(arg) for func, arg in zip(self.type_checkers, args))]
302 try:
--> 303 return func(*args, **kwargs)
304 except TypeError as ex:
305 raise DispatchError(f"Function {func.__code__}") from ex
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/pandas/summary_pandas.py in pandas_describe_1d(config, series, summarizer, typeset)
48 vtype = typeset.detect_type(series)
49
---> 50 return summarizer.summarize(config, series, dtype=vtype)
51
52
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/summarizer.py in summarize(self, config, series, dtype)
35 object:
36 """
---> 37 _, _, summary = self.handle(str(dtype), config, series, {"type": str(dtype)})
38 return summary
39
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/handler.py in handle(self, dtype, *args, **kwargs)
60 funcs = self.mapping.get(dtype, [])
61 op = compose(funcs)
---> 62 return op(*args)
63
64
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/handler.py in func2(*x)
19 return f(*x)
20 else:
---> 21 return f(*res)
22
23 return func2
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/handler.py in func2(*x)
19 return f(*x)
20 else:
---> 21 return f(*res)
22
23 return func2
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/handler.py in func2(*x)
19 return f(*x)
20 else:
---> 21 return f(*res)
22
23 return func2
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/handler.py in func2(*x)
15 def func(f: Callable, g: Callable) -> Callable:
16 def func2(*x) -> Any:
---> 17 res = g(*x)
18 if type(res) == bool:
19 return f(*x)
/databricks/python/lib/python3.8/site-packages/multimethod/__init__.py in __call__(self, *args, **kwargs)
301 func = self[tuple(func(arg) for func, arg in zip(self.type_checkers, args))]
302 try:
--> 303 return func(*args, **kwargs)
304 except TypeError as ex:
305 raise DispatchError(f"Function {func.__code__}") from ex
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/summary_algorithms.py in inner(config, series, summary)
63 if not summary["hashable"]:
64 return config, series, summary
---> 65 return fn(config, series, summary)
66
67 return inner
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/summary_algorithms.py in inner(config, series, summary)
80 series = series.dropna()
81
---> 82 return fn(config, series, summary)
83
84 return inner
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/pandas/describe_numeric_pandas.py in pandas_describe_numeric_1d(config, series, summary)
113
114 if chi_squared_threshold > 0.0:
--> 115 stats["chi_squared"] = chi_square(finite_values)
116
117 stats["range"] = stats["max"] - stats["min"]
/databricks/python/lib/python3.8/site-packages/pandas_profiling/model/summary_algorithms.py in chi_square(values, histogram)
50 ) -> dict:
51 if histogram is None:
---> 52 histogram, _ = np.histogram(values, bins="auto")
53 return dict(chisquare(histogram)._asdict())
54
<__array_function__ internals> in histogram(*args, **kwargs)
/databricks/python/lib/python3.8/site-packages/numpy/lib/histograms.py in histogram(a, bins, range, normed, weights, density)
854 # The index computation is not guaranteed to give exactly
855 # consistent results within ~1 ULP of the bin edges.
--> 856 decrement = tmp_a < bin_edges[indices]
857 indices[decrement] -= 1
858 # The last bin includes the right edge. The other bins do not.
IndexError: index 10 is out of bounds for axis 0 with size 9
Describe the bug
Profile report HTML cannot be generated for dataframes with very large integers. It seems like an overflow issue. Would it be possible to fix this? Even if a report for this series cannot be generated, it would be great if pandas-profiling could at least handle it gracefully so that the code does not crash. For example, if one of the series in a dataframe would encounter this issue, would it be possible to omit it from the report, and only report on the other series?
To Reproduce
Full stack trace
Version information:
Python version: 3.8.10 (default, Nov 26 2021, 20:14:08)
Environment: jupyter notebook
Click to expand Version information
Additional context
The text was updated successfully, but these errors were encountered: