Skip to content

BUG: DataFrame.round() drops column index name #11986

Closed
@iyer

Description

@iyer
  • DataFrame.round() drops the index name in the column
  • This is also seen when using np.round() on the dataframe.
  • Further this is not seen when using other elementwise numpy operations such as np.floor()
  • This is only observed in pandas 0.17.* This was working fine in pandas 0.16.*
import pandas as pd
import numpy as np

rows=5
cols=2
index = pd.Index(range(rows), name='MYINDEX')
columns = pd.Index(range(cols), name='MYCOLUMNS')
df = pd.DataFrame(np.random.rand(rows,cols), index=index, columns=columns)

df
Out[2]: 
MYCOLUMNS         0         1
MYINDEX                      
0          0.163862  0.828853
1          0.560261  0.980514
2          0.736242  0.055051
3          0.825197  0.783094
4          0.153369  0.069713

df.round(2)
Out[3]: 
            0     1
MYINDEX            
0        0.16  0.83
1        0.56  0.98
2        0.74  0.06
3        0.83  0.78
4        0.15  0.07

np.round(df, 2)
Out[4]: 
            0     1
MYINDEX            
0        0.16  0.83
1        0.56  0.98
2        0.74  0.06
3        0.83  0.78
4        0.15  0.07

np.floor(df)
Out[5]: 
MYCOLUMNS  0  1
MYINDEX        
0          0  0
1          0  0
2          0  0
3          0  0
4          0  0

pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 2.6.32-431.11.2.el6.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.2
scipy: 0.16.1
statsmodels: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.10
pymysql: None
psycopg2: None
Jinja2: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions