Skip to content

Commit c8728e2

Browse files
author
y-p
committed
Merge pull request #3280 from y-p/GH3275
ENH: add to_series() method to Index and subclasses GH3275
2 parents 1569838 + 004a25b commit c8728e2

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
@@ -50,6 +50,8 @@ pandas 0.11.0
5050
- Added support for expression evaluation using the ``numexpr`` library
5151
- Added ``convert=boolean`` to ``take`` routines to translate negative
5252
indices to positive, defaults to True
53+
- Added to_series() method to indices, to facilitate the creation of indexeres
54+
(GH3275_)
5355

5456
**Improvements to existing features**
5557

@@ -292,6 +294,7 @@ pandas 0.11.0
292294
.. _GH1893: https://github.com/pydata/pandas/issues/1893
293295
.. _GH1978: https://github.com/pydata/pandas/issues/1978
294296
.. _GH2758: https://github.com/pydata/pandas/issues/2758
297+
.. _GH3275: https://github.com/pydata/pandas/issues/3275
295298
.. _GH2121: https://github.com/pydata/pandas/issues/2121
296299
.. _GH3247: https://github.com/pydata/pandas/issues/3247
297300
.. _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)