Skip to content

BUG: np.round does not work on a series in 0.18.0 #12600

Closed
@wholmgren

Description

@wholmgren

First, conda install pandas is currently pulling down 0.18.0, which was unexpected since I only see RCs right now, but, on to the real issue...

In 0.18.0 I cannot pass a series to np.round...

In [35]: np.round(pd.Series([1.11, 2.21]), 1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-4cc66a785b99> in <module>()
----> 1 np.round(pd.Series([1.11, 2.21]), 1)

/Users/holmgren/miniconda3/envs/pvlib35/lib/python3.5/site-packages/numpy/core/fromnumeric.py in round_(a, decimals, out)
   2784     except AttributeError:
   2785         return _wrapit(a, 'round', decimals, out)
-> 2786     return round(decimals, out)
   2787
   2788

TypeError: round() takes from 1 to 2 positional arguments but 3 were given

np.round does still work on a DataFrame in 0.18.0...

In [5]: np.round(pd.DataFrame([1.11,2.22]), 1)
Out[5]:
     0
0  1.1
1  2.2

A Series on pandas 0.17.1...

In [4]: np.round(pd.Series([1.12, 2.22]), 1)
Out[4]:
0    1.1
1    2.2
dtype: float64

Ok, I know that there's now a round method in pandas (which is great), but I like to use np.round in unit tests so that I can test against earlier versions of pandas.

Version info:

In [34]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.0
setuptools: 20.2.2
Cython: None
numpy: 1.10.4
scipy: 0.17.0
statsmodels: None
xarray: None
IPython: 4.1.1
sphinx: 1.3.5
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas 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