Skip to content

Commit db12d2f

Browse files
committed
Add BalancingLearner.to_dataframe
1 parent a1dcefd commit db12d2f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

adaptive/learner/balancing_learner.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
from adaptive.notebook_integration import ensure_holoviews
1212
from adaptive.utils import cache_latest, named_product, restore
1313

14+
try:
15+
import pandas
16+
17+
with_pandas = True
18+
19+
except ModuleNotFoundError:
20+
with_pandas = False
21+
1422

1523
def dispatch(child_functions, arg):
1624
index, x = arg
@@ -381,6 +389,13 @@ def from_product(cls, f, learner_type, learner_kwargs, combos):
381389
learners.append(learner)
382390
return cls(learners, cdims=arguments)
383391

392+
def to_dataframe(self, kwargs):
393+
if not with_pandas:
394+
raise ImportError("pandas is not installed.")
395+
dfs = [learner.to_dataframe(**kwargs) for learner in self.learners]
396+
df = pandas.concat(dfs, axis=0, ignore_index=True)
397+
return df
398+
384399
def save(self, fname, compress=True):
385400
"""Save the data of the child learners into pickle files
386401
in a directory.

0 commit comments

Comments
 (0)