Skip to content

Commit 004a25b

Browse files
author
y-p
committed
ENH: add to_series() method to Index and subclasses GH3275
1 parent de55824 commit 004a25b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

RELEASE.rst

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pandas 0.11.0
4949
- Added support for expression evaluation using the ``numexpr`` library
5050
- Added ``convert=boolean`` to ``take`` routines to translate negative
5151
indices to positive, defaults to True
52+
- Added to_series() method to indices, to facilitate the creation of indexeres
53+
(GH3275_)
5254

5355
**Improvements to existing features**
5456

@@ -277,6 +279,7 @@ pandas 0.11.0
277279
.. _GH1893: https://github.com/pydata/pandas/issues/1893
278280
.. _GH1978: https://github.com/pydata/pandas/issues/1978
279281
.. _GH2758: https://github.com/pydata/pandas/issues/2758
282+
.. _GH3275: https://github.com/pydata/pandas/issues/3275
280283
.. _GH2121: https://github.com/pydata/pandas/issues/2121
281284
.. _GH3247: https://github.com/pydata/pandas/issues/3247
282285
.. _GH2809: https://github.com/pydata/pandas/issues/2809

doc/source/v0.11.0.txt

+4
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ Astype conversion on ``datetime64[ns]`` to ``object``, implicity converts ``NaT`
226226
API changes
227227
~~~~~~~~~~~
228228

229+
- Added to_series() method to indicies, to facilitate the creation of indexers
230+
(GH3275_)
231+
229232
- In ``HDFStore``, added the method ``select_column`` to select a single column from a table as a Series.
230233

231234
- In ``HDFStore``, deprecated the ``unique`` method, can be replicated by ``select_column(key,column).unique()``
@@ -343,6 +346,7 @@ on GitHub for a complete list.
343346
.. _GH2807: https://github.com/pydata/pandas/issues/2807
344347
.. _GH2918: https://github.com/pydata/pandas/issues/2918
345348
.. _GH2758: https://github.com/pydata/pandas/issues/2758
349+
.. _GH3275: https://github.com/pydata/pandas/issues/3275
346350
.. _GH2979: https://github.com/pydata/pandas/issues/2979
347351
.. _GH3011: https://github.com/pydata/pandas/issues/3011
348352
.. _GH3076: https://github.com/pydata/pandas/issues/3076

pandas/core/index.py

+8
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ def __repr__(self):
188188
"""
189189
return str(self)
190190

191+
def to_series(self):
192+
"""
193+
return a series with both index and values equal to the index keys
194+
useful with map for returning an indexer based on an index
195+
"""
196+
import pandas as pd
197+
return pd.Series(self.values,index=self,name=self.name)
198+
191199
def astype(self, dtype):
192200
return Index(self.values.astype(dtype), name=self.name,
193201
dtype=dtype)

0 commit comments

Comments
 (0)