A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11763 below:

Using built-in round on a series · Issue #11763 · pandas-dev/pandas · GitHub

Is there some philosophical reason that round(Series) and round(Dataframe) is not defined? See the example below. Being able to write round() as a function of a Dataframe or Series, as opposed to doing it afterwards would be nice. I'm willing to implement __round__() to make it work, but don't want to go down that path if there is some reason __round__() is not implemented.

Example:

    import pandas as pd
    import numpy as np
    df =  pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
    print (df.A.round())
    print (round(df))

Produces

0   -2
1    1
2   -1
3   -1
4    2
5    0
6    0
7    0
8   -2
9    0
Name: A, dtype: float64
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-9d2be9cbdc70> in <module>()
      3 df =  pd.DataFrame(np.random.randn(10, 3), columns=['A', 'B', 'C'])
      4 print (df.A.round())
----> 5 print (round(df))

TypeError: type DataFrame doesn't define __round__ method

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4