Skip to content

Commit 68fd6c5

Browse files
committed
Update docs up to accessor
1 parent ab0e74d commit 68fd6c5

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/pandas_openscm/accessors/dataframe.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,11 @@ def update_index_levels(
838838
def update_index_levels_from_other(
839839
self,
840840
update_sources: dict[
841-
Any, tuple[Any, Callable[[Any], Any] | dict[Any, Any] | pd.Series[Any]]
841+
Any,
842+
tuple[
843+
Any | tuple[Any, ...],
844+
Callable[[Any], Any] | dict[Any, Any] | pd.Series[Any],
845+
],
842846
],
843847
copy: bool = True,
844848
remove_unused_levels: bool = True,
@@ -849,18 +853,29 @@ def update_index_levels_from_other(
849853
Parameters
850854
----------
851855
update_sources
852-
Updates to apply to `df`'s index
856+
Updates to apply to the data's index
853857
854858
Each key is the level to which the updates will be applied
855859
(or the level that will be created if it doesn't already exist).
856860
857-
Each value is a tuple of which the first element
861+
There are two options for the values.
862+
863+
The first is used when only one level is used to update the 'target level'.
864+
In this case, each value is a tuple of which the first element
858865
is the level to use to generate the values (the 'source level')
859866
and the second is mapper of the form used by
860867
[pd.Index.map][pandas.Index.map]
861868
which will be applied to the source level
862869
to update/create the level of interest.
863870
871+
Each value is a tuple of which the first element
872+
is the level or levels (if a tuple)
873+
to use to generate the values (the 'source level')
874+
and the second is mapper of the form used by
875+
[pd.Index.map][pandas.Index.map]
876+
which will be applied to the source level
877+
to update/create the level of interest.
878+
864879
copy
865880
Should the [pd.DataFrame][pandas.DataFrame] be copied before returning?
866881

src/pandas_openscm/index_manipulation.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,11 @@ def update_levels(
611611
def update_index_levels_from_other_func(
612612
df: pd.DataFrame,
613613
update_sources: dict[
614-
Any, tuple[Any, Callable[[Any], Any] | dict[Any, Any] | pd.Series[Any]]
614+
Any,
615+
tuple[
616+
Any | tuple[Any, ...],
617+
Callable[[Any], Any] | dict[Any, Any] | pd.Series[Any],
618+
],
615619
],
616620
copy: bool = True,
617621
remove_unused_levels: bool = True,
@@ -633,13 +637,24 @@ def update_index_levels_from_other_func(
633637
Each key is the level to which the updates will be applied
634638
(or the level that will be created if it doesn't already exist).
635639
636-
Each value is a tuple of which the first element
640+
There are two options for the values.
641+
642+
The first is used when only one level is used to update the 'target level'.
643+
In this case, each value is a tuple of which the first element
637644
is the level to use to generate the values (the 'source level')
638645
and the second is mapper of the form used by
639646
[pd.Index.map][pandas.Index.map]
640647
which will be applied to the source level
641648
to update/create the level of interest.
642649
650+
Each value is a tuple of which the first element
651+
is the level or levels (if a tuple)
652+
to use to generate the values (the 'source level')
653+
and the second is mapper of the form used by
654+
[pd.Index.map][pandas.Index.map]
655+
which will be applied to the source level
656+
to update/create the level of interest.
657+
643658
copy
644659
Should `df` be copied before returning?
645660

0 commit comments

Comments
 (0)