You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
should astype TRY to convert string columns (e.g. if the value of the string column is like '5'), or skip if its an exception (and just return it), rather than raise an exception on the whole operation?
I can fix for 0.10.2
In [4]: df = pd.DataFrame({ 'a' : 'foo', 'b' : 1. },index=np.arange(10))
In [6]: df .dtypes
Out[6]:
a object
b float64
In [8]: df.astype('float64')
/mnt/home/jreback/pandas/pandas/core/internals.pyc in astype(self, dtype)
613 new_blocks = []
614 for block in self.blocks:
--> 615 newb = make_block(com._astype_nansafe(block.values, dtype),
616 block.items, block.ref_items)
617 new_blocks.append(newb)
/mnt/home/jreback/pandas/pandas/core/common.pyc in _astype_nansafe(arr, dtype)
1058 return lib.astype_intsafe(arr.ravel(), dtype).reshape(arr.shape)
1059
-> 1060 return arr.astype(dtype)
1061
1062
ValueError: could not convert string to float: foo
The text was updated successfully, but these errors were encountered:
I think the default behavior should stay as is, but I see nothing wrong with adding a raise keyword that is True by default and can be set to False so errors are passed silently and whatever can be converted is converted
should astype TRY to convert string columns (e.g. if the value of the string column is like '5'), or skip if its an exception (and just return it), rather than raise an exception on the whole operation?
I can fix for 0.10.2
The text was updated successfully, but these errors were encountered: