Repository: ydataai/ydata-profiling

Issue:
Extreme Values - Improper Count in Sub-Tab Headers
On the Extreme Values tab of a generated HTML report, there are two tabs. They indicate 5 min and max values should be shown; however, in reality, there are 10 values shown under each tab.

I would expect the number displayed in the tab heading to match the actual number of records shown.

Minimal reproduction:
![image](https://user-images.githubusercontent.com/12687723/138352817-3dafb7e2-2b7e-4339-bf02-00948988f9fb.png)

I'm happy to tackle this. Should it be changed to read "Minimum 10 values" and "Maximum 10 values"?


Discussion:
Good catch, this  is certainly a bug.  We should look into  if this is a configuration or rendering issue. Are you interested in picking this up?
Happy to contribute. The tab's message is fixed to say 5. Do you want me to change the string to read 10?
The number of observations is configurable, so replacing the hard-coded value with the configured value should resolve the  issue. A PR is very much welcome.

Resolving patch:
diff --git a/src/pandas_profiling/report/structure/variables/render_count.py b/src/pandas_profiling/report/structure/variables/render_count.py
--- a/src/pandas_profiling/report/structure/variables/render_count.py
+++ b/src/pandas_profiling/report/structure/variables/render_count.py
@@ -123,13 +123,13 @@ def render_count(config: Settings, summary: dict) -> dict:
         [
             FrequencyTable(
                 template_variables["firstn_expanded"],
-                name="Minimum 5 values",
+                name=f"Minimum {config.n_extreme_obs} values",
                 anchor_id="firstn",
                 redact=False,
             ),
             FrequencyTable(
                 template_variables["lastn_expanded"],
-                name="Maximum 5 values",
+                name=f"Maximum {config.n_extreme_obs} values",
                 anchor_id="lastn",
                 redact=False,
             ),
diff --git a/src/pandas_profiling/report/structure/variables/render_real.py b/src/pandas_profiling/report/structure/variables/render_real.py
--- a/src/pandas_profiling/report/structure/variables/render_real.py
+++ b/src/pandas_profiling/report/structure/variables/render_real.py
@@ -250,13 +250,13 @@ def render_real(config: Settings, summary: dict) -> dict:
         [
             FrequencyTable(
                 template_variables["firstn_expanded"],
-                name="Minimum 5 values",
+                name=f"Minimum {config.n_extreme_obs} values",
                 anchor_id=f"{varid}firstn",
                 redact=False,
             ),
             FrequencyTable(
                 template_variables["lastn_expanded"],
-                name="Maximum 5 values",
+                name=f"Maximum {config.n_extreme_obs} values",
                 anchor_id=f"{varid}lastn",
                 redact=False,
             ),


Test patch:
diff --git a/tests/issues/test_issue864.py b/tests/issues/test_issue864.py
new file mode 100644
--- /dev/null
+++ b/tests/issues/test_issue864.py
@@ -0,0 +1,37 @@
+"""
+Test for issue 864:
+https://github.com/pandas-profiling/pandas-profiling/issues/
+
+Validate Extreme Values sub-tabs state the correct number of extreme values shown.
+"""
+import pandas as pd
+import random
+import fnmatch
+
+from pandas_profiling import ProfileReport
+
+
+def test_issue864():
+    def random_list(n):
+        return [random.randrange(0, 100) for _ in range(0, n)]
+
+    df = pd.DataFrame({'a': random_list(30)})
+
+    profile = ProfileReport(df)
+
+    def test_with_value(n_extreme_obs):
+        """Generate HTML and validate the tabs contain the proper tab titles."""
+        profile.config.n_extreme_obs = n_extreme_obs
+        profile.invalidate_cache()
+
+        reg_min = f'*<a href=* aria-controls=* role=tab data-toggle=tab>Minimum {n_extreme_obs} values</a>*'
+        reg_max = f'*<a href=* aria-controls=* role=tab data-toggle=tab>Maximum {n_extreme_obs} values</a>*'
+        
+        html = profile.to_html()
+
+        assert fnmatch.fnmatch(html, reg_min)
+        assert fnmatch.fnmatch(html, reg_max)
+
+    test_with_value(5)
+    test_with_value(10)
+    test_with_value(12)