Skip to content

Commit 7e5b422

Browse files
committed
Pass failing test
1 parent 585cfcf commit 7e5b422

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/pandas_openscm/accessors/dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def to_category_index(self) -> pd.DataFrame:
675675
Returns
676676
-------
677677
:
678-
[pd.DataFrame][pandas.DataFrame] with all index columns
678+
[pd.DataFrame][pandas.DataFrame] with all index levels
679679
converted to category type.
680680
"""
681681
return convert_index_to_category_index(self._df)

src/pandas_openscm/accessors/series.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
groupby_except,
1515
)
1616
from pandas_openscm.index_manipulation import (
17+
convert_index_to_category_index,
1718
ensure_index_is_multiindex,
1819
set_index_levels_func,
1920
)
@@ -364,22 +365,22 @@ def set_index_levels(
364365
# Figuring this out is a job for another day
365366
return res # type: ignore
366367

367-
# def to_category_index(self) -> pd.DataFrame:
368-
# """
369-
# Convert the index's values to categories
370-
#
371-
# This can save a lot of memory and improve the speed of processing.
372-
# However, it comes with some pitfalls.
373-
# For a nice discussion of some of them,
374-
# see [this article](https://towardsdatascience.com/staying-sane-while-adopting-pandas-categorical-datatypes-78dbd19dcd8a/).
375-
#
376-
# Returns
377-
# -------
378-
# :
379-
# [pd.DataFrame][pandas.DataFrame] with all index columns
380-
# converted to category type.
381-
# """
382-
# return convert_index_to_category_index(self._df)
368+
def to_category_index(self) -> S:
369+
"""
370+
Convert the index's values to categories
371+
372+
This can save a lot of memory and improve the speed of processing.
373+
However, it comes with some pitfalls.
374+
For a nice discussion of some of them,
375+
see [this article](https://towardsdatascience.com/staying-sane-while-adopting-pandas-categorical-datatypes-78dbd19dcd8a/).
376+
377+
Returns
378+
-------
379+
:
380+
[pd.Series][pandas.Series] with all index levels
381+
converted to category type.
382+
"""
383+
return convert_index_to_category_index(self._series)
383384

384385
# def update_index_levels(
385386
# self,

0 commit comments

Comments
 (0)