Skip to content

Commit 9b64055

Browse files
v0.0.29
Example added
1 parent 689fca8 commit 9b64055

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.0.28"
10+
version = "0.0.29"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/utils/aggregate.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pandas as pd
22
import numpy as np
33

4+
45
def aggregate_mean_var(X, y, sort=False):
56
"""
67
Aggregate array to mean.
@@ -14,6 +15,18 @@ def aggregate_mean_var(X, y, sort=False):
1415
(numpy.ndarray): aggregated `X` values, shape `(n-m, k)`, if `m` duplicates in `X`.
1516
(numpy.ndarray): aggregated (mean per group) `y` values, shape `(1,)`, if `m` duplicates in `X`.
1617
(numpy.ndarray): aggregated (variance per group) `y` values, shape `(1,)`, if `m` duplicates in `X`.
18+
19+
Example:
20+
>>> X = np.array([[1, 2], [3, 4], [1, 2]])
21+
>>> y = np.array([1, 2, 3])
22+
>>> X_agg, y_mean, y_var = aggregate_mean_var(X, y)
23+
>>> print(X_agg)
24+
[[1. 2.]
25+
[3. 4.]]
26+
>>> print(y_mean)
27+
[2. 2.]
28+
>>> print(y_var)
29+
[1. 0.]
1730
"""
1831
# Create a DataFrame from X and y
1932
df = pd.DataFrame(X)

0 commit comments

Comments
 (0)