From 15f89ce3b2ab32db6a2edb105111b8ac9f1d33f7 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Thu, 21 Feb 2013 11:47:38 -0500 Subject: [PATCH] BUG: incorrect default in df.convert_objects was converting object types in applymap (#2909) DOC: typos in RELEASE.rst --- RELEASE.rst | 25 ++++++++++++++++--------- pandas/core/frame.py | 2 +- pandas/tests/test_frame.py | 9 +++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) mode change 100644 => 100755 RELEASE.rst mode change 100644 => 100755 pandas/core/frame.py mode change 100644 => 100755 pandas/tests/test_frame.py diff --git a/RELEASE.rst b/RELEASE.rst old mode 100644 new mode 100755 index 603a928eda74e..00f1f9375306a --- a/RELEASE.rst +++ b/RELEASE.rst @@ -41,10 +41,11 @@ pandas 0.11.0 - added ``blocks`` attribute to DataFrames, to return a dict of dtypes to homogeneously dtyped DataFrames - added keyword ``convert_numeric`` to ``convert_objects()`` to try to - convert object dtypes to numeric types + convert object dtypes to numeric types (default is False) - ``convert_dates`` in ``convert_objects`` can now be ``coerce`` which will return a datetime64[ns] dtype with non-convertibles set as ``NaT``; will - preserve an all-nan object (e.g. strings) + preserve an all-nan object (e.g. strings), default is True (to perform + soft-conversion - Series print output now includes the dtype by default - Optimize internal reindexing routines (GH2819_, GH2867_) - ``describe_option()`` now reports the default and current value of options. @@ -69,12 +70,14 @@ pandas 0.11.0 - Integer block types will upcast as needed in where operations (GH2793_) - Series now automatically will try to set the correct dtype based on passed datetimelike objects (datetime/Timestamp) - - timedelta64 are returned in appropriate cases (e.g. Series - Series, - when both are datetime64) - - mixed datetimes and objects (GH2751_) in a constructor witll be casted - correctly - - astype on datetimes to object are now handled (as well as NaT - conversions to np.nan) + + - timedelta64 are returned in appropriate cases (e.g. Series - Series, + when both are datetime64) + - mixed datetimes and objects (GH2751_) in a constructor witll be casted + correctly + - astype on datetimes to object are now handled (as well as NaT + conversions to np.nan) + - arguments to DataFrame.clip were inconsistent to numpy and Series clipping (GH2747_) @@ -92,7 +95,7 @@ pandas 0.11.0 overflow ``int64`` and some mixed typed type lists (GH2845_) - Fix issue with slow printing of wide frames resulting (GH2807_) - ``HDFStore`` + - ``HDFStore`` - Fix weird PyTables error when using too many selectors in a where - Provide dotted attribute access to ``get`` from stores @@ -100,6 +103,9 @@ pandas 0.11.0 - Internally, change all variables to be private-like (now have leading underscore) + - Bug showing up in applymap where some object type columns are converted (GH2909_) + had an incorrect default in convert_objects + .. _GH622: https://github.com/pydata/pandas/issues/622 .. _GH797: https://github.com/pydata/pandas/issues/797 .. _GH2681: https://github.com/pydata/pandas/issues/2681 @@ -113,6 +119,7 @@ pandas 0.11.0 .. _GH2845: https://github.com/pydata/pandas/issues/2845 .. _GH2867: https://github.com/pydata/pandas/issues/2867 .. _GH2807: https://github.com/pydata/pandas/issues/2807 +.. _GH2909: https://github.com/pydata/pandas/issues/2909 pandas 0.10.1 ============= diff --git a/pandas/core/frame.py b/pandas/core/frame.py old mode 100644 new mode 100755 index 486924eca456f..4301aac566fc6 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1658,7 +1658,7 @@ def info(self, verbose=True, buf=None, max_cols=None): def dtypes(self): return self.apply(lambda x: x.dtype) - def convert_objects(self, convert_dates=True, convert_numeric=True): + def convert_objects(self, convert_dates=True, convert_numeric=False): """ Attempt to infer better dtype for object columns Always returns a copy (even if no object columns) diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py old mode 100644 new mode 100755 index 9555f924ef58e..a0dbe760bd405 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -6793,6 +6793,15 @@ def test_applymap(self): result = self.frame.applymap(lambda x: (x, x)) self.assert_(isinstance(result['A'][0], tuple)) + # GH 2909, object conversion to float in constructor? + df = DataFrame(data=[1,'a']) + result = df.applymap(lambda x: x) + self.assert_(result.dtypes[0] == object) + + df = DataFrame(data=[1.,'a']) + result = df.applymap(lambda x: x) + self.assert_(result.dtypes[0] == object) + def test_filter(self): # items