Skip to content

Commit

Permalink
python/examples/plot_pandas.py: Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Oct 28, 2024
1 parent f17ff3c commit ae04c4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def setup(app):
# To exclude everything, use: '.*'
"exclude_implicit_doc": {r"pyplot\.show"},
"show_memory": False,
# "reference_url": {"mooplot": None},
"reference_url": {project: None},
# "subsection_order": SubSectionTitleOrder("../examples"),
# "within_subsection_order": SKExampleTitleSortKey,
# "binder": {
Expand Down
13 changes: 8 additions & 5 deletions python/examples/plot_pandas.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""Using moocore with Pandas
==========================
This example shows how to use ``moocore`` functions with ``pandas`` (https://pandas.pydata.org/).
This example shows how to use ``moocore`` functions with Pandas (https://pandas.pydata.org/).
"""

import pandas as pd
import moocore

# %%
# First, we create a toy Pandas DataFrame.
# First, we create a toy Pandas :class:`~pandas.DataFrame`.

df = pd.DataFrame(
dict(
Expand All @@ -29,7 +29,7 @@
df

# %%
# Now we calculate the hypervolume for each algo using :meth:`pandas.core.groupby.DataFrameGroupBy.apply`.
# Now we calculate the hypervolume for each ``algo`` using :meth:`~pandas.DataFrame.groupby` and :meth:`~pandas.core.groupby.DataFrameGroupBy.apply`.

ref = 2.1
hv = (
Expand All @@ -50,7 +50,10 @@


# %%
# Note that :func:`moocore.apply_within_sets()` processes each group in order, even if the elements of the same group are not contiguous. That is, it processes the groups like :meth:`pandas.Series.unique` and not like :class:`set` or :func:`numpy.unique()`.
# Note that :func:`moocore.apply_within_sets()` processes each group in
# order, even if the elements of the same group are not contiguous. That is, it
# processes the groups like :meth:`pandas.Series.unique` and not like
# :class:`set` or :func:`numpy.unique()`.

df["algo"].unique()

Expand All @@ -69,7 +72,7 @@
df

# %%
# We can still use :meth:`pandas.DataFrame.groupby` but we may need to reset and clean-up the index.
# We can still use :meth:`~pandas.DataFrame.groupby` but we may need to reset and clean-up the index.

df.groupby(["algo", "run"]).apply(
moocore.filter_dominated, include_groups=False
Expand Down

0 comments on commit ae04c4c

Please sign in to comment.