Skip to content

Commit 008580d

Browse files
committed
Merge pull request #3502 from jreback/GH3480
BUG: GH3480 Fix regression in a DataFrame apply with axis=1
2 parents da8be66 + 0bb4820 commit 008580d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

RELEASE.rst

+3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ pandas 0.11.1
5858
- Duplicate indexes with getitem will return items in the correct order (GH3455_, GH3457_)
5959
- Fix sorting in a frame with a list of columns which contains datetime64[ns] dtypes (GH3461_)
6060
- DataFrames fetched via FRED now handle '.' as a NaN. (GH3469_)
61+
- Fix regression in a DataFrame apply with axis=1, objects were not being converted back
62+
to base dtypes correctly (GH3480_)
6163

6264
.. _GH3164: https://github.com/pydata/pandas/issues/3164
6365
.. _GH3251: https://github.com/pydata/pandas/issues/3251
6466
.. _GH3379: https://github.com/pydata/pandas/issues/3379
67+
.. _GH3480: https://github.com/pydata/pandas/issues/3480
6568
.. _GH3454: https://github.com/pydata/pandas/issues/3454
6669
.. _GH3457: https://github.com/pydata/pandas/issues/3457
6770
.. _GH3426: https://github.com/pydata/pandas/issues/3426

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4210,7 +4210,7 @@ def _apply_standard(self, func, axis, ignore_failures=False):
42104210

42114211
if axis == 1:
42124212
result = result.T
4213-
result = result.convert_objects(convert_dates=False)
4213+
result = result.convert_objects()
42144214

42154215
return result
42164216
else:

pandas/tests/test_groupby.py

+7
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,13 @@ def convert_force_pure(x):
18261826
self.assert_(result.dtype == np.object_)
18271827
self.assert_(isinstance(result[0], Decimal))
18281828

1829+
def test_apply_with_mixed_dtype(self):
1830+
# GH3480, apply with mixed dtype on axis=1 breaks in 0.11
1831+
df = DataFrame({'foo1' : ['one', 'two', 'two', 'three', 'one', 'two'],
1832+
'foo2' : np.random.randn(6)})
1833+
result = df.apply(lambda x: x, axis=1)
1834+
assert_series_equal(df.get_dtype_counts(), result.get_dtype_counts())
1835+
18291836
def test_groupby_list_infer_array_like(self):
18301837
result = self.df.groupby(list(self.df['A'])).mean()
18311838
expected = self.df.groupby(self.df['A']).mean()

0 commit comments

Comments
 (0)