Skip to content

API: Index.map should return Index rather than array #12766

Closed
@den-run-ai

Description

@den-run-ai
df2=pd.DataFrame([[0,1],[2,3]],columns=['c1','c2'],index=['i1','i2'])
df2.index.name='index'
df2.to_html()
<table border="1" class="dataframe">\n  <thead>\n    <tr style="text-align: right;">\n      <th></th>\n      <th>c1</th>\n      <th>c2</th>\n    </tr>\n    <tr>\n      <th>index</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>i1</th>\n      <td>0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>i2</th>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>
df2.index = df2.index.map(lambda x: x.upper())
df2.to_html()
<table border="1" class="dataframe">\n  <thead>\n    <tr style="text-align: right;">\n      <th></th>\n      <th>c1</th>\n      <th>c2</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>I1</th>\n      <td>0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>I2</th>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>

I think map should accept inplace

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.1
setuptools: 18.2
Cython: None
numpy: 1.10.4
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.1
pytz: 2016.2
blosc: None
bottleneck: 1.0.0
tables: None
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignCompatpandas objects compatability with Numpy or Python functions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions