Skip to content

Commit

Permalink
BUG: Fixed Series.align(frame) with ExtensionArray (pandas-dev#20580)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger authored and jorisvandenbossche committed Apr 3, 2018
1 parent 6f7f367 commit d305d6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
is_complex, is_datetimetz, is_categorical_dtype,
is_datetimelike,
is_extension_type,
is_extension_array_dtype,
is_object_dtype,
is_datetime64tz_dtype, is_datetime64_dtype,
is_datetime64_ns_dtype,
Expand Down Expand Up @@ -329,7 +330,7 @@ def maybe_promote(dtype, fill_value=np.nan):
dtype = np.object_

# in case we have a string that looked like a number
if is_categorical_dtype(dtype):
if is_extension_array_dtype(dtype):
pass
elif is_datetimetz(dtype):
pass
Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/extension/base/reshaping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import numpy as np

import pandas as pd
from pandas.core.internals import ExtensionBlock
Expand Down Expand Up @@ -64,6 +65,19 @@ def test_align_frame(self, data, na_value):
self.assert_frame_equal(r1, e1)
self.assert_frame_equal(r2, e2)

def test_align_series_frame(self, data, na_value):
# https://github.com/pandas-dev/pandas/issues/20576
ser = pd.Series(data, name='a')
df = pd.DataFrame({"col": np.arange(len(ser) + 1)})
r1, r2 = ser.align(df)

e1 = pd.Series(
data._constructor_from_sequence(list(data) + [na_value]),
name=ser.name)

self.assert_series_equal(r1, e1)
self.assert_frame_equal(r2, df)

def test_set_frame_expand_regular_with_extension(self, data):
df = pd.DataFrame({"A": [1] * len(data)})
df['B'] = data
Expand Down

0 comments on commit d305d6a

Please sign in to comment.