|
14 | 14 | groupby_except, |
15 | 15 | ) |
16 | 16 | from pandas_openscm.index_manipulation import ( |
| 17 | + convert_index_to_category_index, |
17 | 18 | ensure_index_is_multiindex, |
18 | 19 | set_index_levels_func, |
19 | 20 | ) |
@@ -364,22 +365,22 @@ def set_index_levels( |
364 | 365 | # Figuring this out is a job for another day |
365 | 366 | return res # type: ignore |
366 | 367 |
|
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) |
383 | 384 |
|
384 | 385 | # def update_index_levels( |
385 | 386 | # self, |
|
0 commit comments