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/11885 below:

round() method to ignore non-numerical columns? · Issue #11885 · pandas-dev/pandas · GitHub

If you call the new round method on a mixed dataframe (not only numerical columns), you get an error:

In [1]: df = pd.DataFrame({'floats':[0.123, 0.156, 5.687], 'strings': ['a', 'b', 'c']})

In [2]: df.round(2)
TypeError: can't multiply sequence by non-int of type 'float'

In [3]: df.round()
AttributeError: 'str' object has no attribute 'rint'

Would it be better to ignore these non-numerical columns instead of raising an error?
Another option would be to drop these columns (like numerical aggregations like df.mean() do).


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