Skip to content

Commit

Permalink
SNOW-1555437 Fix Index docstrings (#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-azhan authored Jul 26, 2024
1 parent c88209f commit 055e48b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- Removed axis labels and callable names from error messages and telemetry about unsupported aggregations.
- Fixed AssertionError in `Series.drop_duplicates` and `DataFrame.drop_duplicates` when called after `sort_values`.
- Fixed a bug in `Index.to_frame` where the result frame's column name may be wrong where name is unspecified.
- Fixed a bug where some Index docstrings are ignored.


## 1.20.0 (2024-07-17)
Expand Down
25 changes: 14 additions & 11 deletions src/snowflake/snowpark/modin/plugin/extensions/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

from __future__ import annotations

from functools import wraps
from typing import Any, Callable, Hashable, Iterator, Literal

import modin
import numpy as np
import pandas as native_pd
from pandas._libs import lib
Expand All @@ -50,6 +52,7 @@ def is_lazy_check(func: Callable) -> Callable:
Decorator method for separating function calls for lazy indexes and non-lazy (column) indexes
"""

@wraps(func)
def check_lazy(*args: Any, **kwargs: Any) -> Any:
func_name = func.__name__

Expand Down Expand Up @@ -1601,9 +1604,9 @@ def to_series(
@is_lazy_check
def to_frame(
self, index: bool = True, name: Hashable | None = lib.no_default
) -> DataFrame:
) -> modin.pandas.DataFrame:
"""
Create a DataFrame with a column containing the Index.
Create a :class:`DataFrame` with a column containing the Index.
Parameters
----------
Expand All @@ -1616,8 +1619,8 @@ def to_frame(
Returns
-------
DataFrame
DataFrame containing the original Index data.
:class:`DataFrame`
:class:`DataFrame` containing the original Index data.
See Also
--------
Expand All @@ -1627,7 +1630,7 @@ def to_frame(
Examples
--------
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')
>>> idx.to_frame()
>>> idx.to_frame() # doctest: +NORMALIZE_WHITESPACE
animal
animal
Ant Ant
Expand All @@ -1637,10 +1640,10 @@ def to_frame(
By default, the original Index is reused. To enforce a new Index:
>>> idx.to_frame(index=False)
animal
0 Ant
1 Bear
2 Cow
animal
0 Ant
1 Bear
2 Cow
To override the name of the resulting column, specify `name`:
Expand Down Expand Up @@ -2099,9 +2102,9 @@ def get_indexer_for(self, target: Any) -> Any:
Examples
--------
# Snowpark pandas converts np.nan, pd.NA, pd.NaT to None
Note Snowpark pandas converts np.nan, pd.NA, pd.NaT to None
>>> idx = pd.Index([np.nan, 'var1', np.nan])
>>> idx.get_indexer_for([np.nan])
>>> idx.get_indexer_for([None])
array([0, 2])
"""
WarningMessage.index_to_pandas_warning("get_indexer_for")
Expand Down

0 comments on commit 055e48b

Please sign in to comment.