spark-instrumented-optimizer/python/docs/source/reference/pyspark.pandas
Xinrong Meng cb14a32005 [SPARK-36469][PYTHON] Implement Index.map
### What changes were proposed in this pull request?
Implement `Index.map`.

The PR is based on https://github.com/databricks/koalas/pull/2136. Thanks awdavidson for the prototype.

`map` of CategoricalIndex and DatetimeIndex will be implemented in separate PRs.

### Why are the changes needed?
Mapping values using input correspondence (a dict, Series, or function) is supported in pandas as [Index.map](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.map.html).
We shall also support hat.

### Does this PR introduce _any_ user-facing change?
Yes. `Index.map` is available now.

```py
>>> psidx = ps.Index([1, 2, 3])

>>> psidx.map({1: "one", 2: "two", 3: "three"})
Index(['one', 'two', 'three'], dtype='object')

>>> psidx.map(lambda id: "{id} + 1".format(id=id))
Index(['1 + 1', '2 + 1', '3 + 1'], dtype='object')

>>> pser = pd.Series(["one", "two", "three"], index=[1, 2, 3])
>>> psidx.map(pser)
Index(['one', 'two', 'three'], dtype='object')
```

### How was this patch tested?
Unit tests.

Closes #33694 from xinrong-databricks/index_map.

Authored-by: Xinrong Meng <xinrong.meng@databricks.com>
Signed-off-by: Takuya UESHIN <ueshin@databricks.com>
(cherry picked from commit 4dcd746025)
Signed-off-by: Takuya UESHIN <ueshin@databricks.com>
2021-08-16 11:06:23 -07:00
..
extensions.rst [SPARK-35591][PYTHON][DOCS] Rename "Koalas" to "pandas API on Spark" in the documents 2021-06-11 20:42:38 +09:00
frame.rst [SPARK-36239][PYTHON][DOCS] Remove some APIs from documentation 2021-07-22 19:46:49 +09:00
general_functions.rst
groupby.rst
index.rst [SPARK-35750][PYTHON][DOCS] Rename "pandas APIs on Spark" to "pandas API on Spark" 2021-06-15 10:01:04 +09:00
indexing.rst [SPARK-36469][PYTHON] Implement Index.map 2021-08-16 11:06:23 -07:00
io.rst
ml.rst [SPARK-35696][PYTHON][DOCS] Refine the code examples in pandas-on-Spark documentation 2021-06-24 14:48:13 +09:00
series.rst [SPARK-36267][PYTHON] Clean up CategoricalAccessor and CategoricalIndex 2021-07-27 12:17:26 +09:00
window.rst