Skip to content

Commit b04ac64

Browse files
committed
Fixing more test failures
1 parent 97bd19b commit b04ac64

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

pandas/core/internals.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5123,7 +5123,12 @@ def concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy):
51235123
[ju.block for ju in join_units], placement=placement)
51245124
elif is_sparse_join_units(join_units):
51255125
values = concatenate_join_units(join_units, concat_axis, copy=copy)
5126-
values = values[0]
5126+
5127+
if len(values.shape) == 2:
5128+
values = values[0]
5129+
elif len(values.shape) != 1:
5130+
raise 'WTF'
5131+
51275132
block = join_units[0].block
51285133

51295134
if block:

pandas/tests/sparse/frame/test_frame.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,29 +222,34 @@ class Unknown:
222222
'"Unknown" for data argument'):
223223
SparseDataFrame(Unknown())
224224

225-
@pytest.mark.parametrize('fill_value', [0, 1, np.nan, None])
225+
# Cannot use None as a fill_value cause it will overwrite as zeros
226+
@pytest.mark.parametrize('fill_value', [0, 1, np.nan])
226227
def test_constructor_preserve_attr(self, fill_value):
227228
# GH 13866
228229
arr = pd.SparseArray([1, 0, 3, 0], dtype=np.int64,
229230
fill_value=fill_value)
231+
230232
assert arr.dtype == np.int64
231-
assert arr.fill_value == fill_value
233+
tm.assert_almost_equal(arr.fill_value, fill_value)
232234

233235
df = pd.SparseDataFrame({'x': arr})
234236
assert df['x'].dtype == np.int64
235-
assert df['x'].fill_value == fill_value
237+
238+
tm.assert_almost_equal(df['x'].fill_value, fill_value)
236239

237240
s = pd.SparseSeries(arr, name='x')
238241
assert s.dtype == np.int64
239-
assert s.fill_value == fill_value
242+
tm.assert_almost_equal(s.fill_value, fill_value)
240243

241244
df = pd.SparseDataFrame(s)
242245
assert df['x'].dtype == np.int64
243-
assert df['x'].fill_value == fill_value
246+
247+
tm.assert_almost_equal(df['x'].fill_value, fill_value)
244248

245249
df = pd.SparseDataFrame({'x': s})
246250
assert df['x'].dtype == np.int64
247-
assert df['x'].fill_value == fill_value
251+
252+
tm.assert_almost_equal(df['x'].fill_value, fill_value)
248253

249254
def test_constructor_nan_dataframe(self):
250255
# GH 10079

0 commit comments

Comments
 (0)