From 93e3cc7904e21ede21d3f84ad144109c083ab7dd Mon Sep 17 00:00:00 2001 From: sdg Date: Fri, 3 Jan 2020 16:29:31 +0100 Subject: [PATCH] TST: Adding test to concat Sparse arrays --- pandas/tests/reshape/test_concat.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/reshape/test_concat.py b/pandas/tests/reshape/test_concat.py index 2ea7ab827732e..990669f1ae13a 100644 --- a/pandas/tests/reshape/test_concat.py +++ b/pandas/tests/reshape/test_concat.py @@ -28,6 +28,7 @@ read_csv, ) import pandas._testing as tm +from pandas.core.arrays import SparseArray from pandas.core.construction import create_series_with_explicit_dtype from pandas.tests.extension.decimal import to_decimal @@ -2739,3 +2740,13 @@ def test_concat_empty_df_object_dtype(): result = pd.concat([df_1, df_2], axis=0) expected = df_1.astype(object) tm.assert_frame_equal(result, expected) + + +def test_concat_sparse(): + # GH 23557 + a = pd.Series(SparseArray([0, 1, 2])) + expected = pd.DataFrame(data=[[0, 0], [1, 1], [2, 2]]).astype( + pd.SparseDtype(np.int64, 0) + ) + result = pd.concat([a, a], axis=1) + tm.assert_frame_equal(result, expected)