Skip to content

BUG in dealing with deprecated argument in convert_objects  #10601

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

cc @bashtage

The deprecation warning is triggered, but the value of the keyword argument should also be adapted so it still works with the new code I think (from a failure in the docs)

In [1]: from datetime import datetime

In [2]: s = pd.Series([datetime(2001,1,1,0,0), 'foo', 1.0, 1,
   ...:                pd.Timestamp('20010104'), '20010105'], dtype='O')

In [5]: s.convert_objects(convert_dates='coerce')
c:\users\vdbosscj\scipy\pandas-joris\pandas\util\decorators.py:81: FutureWarning
: the 'convert_dates' keyword is deprecated, use 'datetime' instead
  warnings.warn(msg, FutureWarning)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-b962b638ac86> in <module>()
----> 1 s.convert_objects(convert_dates='coerce')

c:\users\vdbosscj\scipy\pandas-joris\pandas\util\decorators.pyc in wrapper(*args
, **kwargs)
     86                 else:
     87                     kwargs[new_arg_name] = new_arg_value
---> 88             return func(*args, **kwargs)
     89         return wrapper
     90     return _deprecate_kwarg

c:\users\vdbosscj\scipy\pandas-joris\pandas\util\decorators.pyc in wrapper(*args
, **kwargs)
     86                 else:
     87                     kwargs[new_arg_name] = new_arg_value
---> 88             return func(*args, **kwargs)
     89         return wrapper
     90     return _deprecate_kwarg

c:\users\vdbosscj\scipy\pandas-joris\pandas\util\decorators.pyc in wrapper(*args
, **kwargs)
     86                 else:
     87                     kwargs[new_arg_name] = new_arg_value
---> 88             return func(*args, **kwargs)
     89         return wrapper
     90     return _deprecate_kwarg

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\generic.py in convert_objects(s
elf, datetime, numeric, timedelta, coerce, copy)
   2468                                timedelta=timedelta,
   2469                                coerce=coerce,
-> 2470                                copy=copy)).__finalize__(self)
   2471
   2472     #-------------------------------------------------------------------

---

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.py in convert(self, *
*kwargs)
   3459         """ convert the whole block as one """
   3460         kwargs['by_item'] = False
-> 3461         return self.apply('convert', **kwargs)
   3462
   3463     @property

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.py in apply(self, f,
axes, filter, do_integrity_check, **kwargs)
   2467                                                  copy=align_copy)
   2468
-> 2469             applied = getattr(b, f)(**kwargs)
   2470
   2471             if isinstance(applied, list):

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\internals.py in convert(self, d
atetime, numeric, timedelta, coerce, copy, by_item)
   1493                 timedelta=timedelta,
   1494                 coerce=coerce,
-> 1495                 copy=copy
   1496             ).reshape(self.values.shape)
   1497             blocks.append(make_block(values,

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\common.py in _possibly_convert_
objects(values, datetime, numeric, timedelta, coerce, copy)
   1897     """ if we have an object dtype, try to coerce dates and/or numbers "
""
   1898
-> 1899     conversion_count = sum((datetime, numeric, timedelta))
   1900     if conversion_count == 0:
   1901         import warnings

TypeError: unsupported operand type(s) for +: 'int' and 'str'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions