Skip to content

Commit 8cff0e1

Browse files
SdgJlbljreback
authored andcommitted
TST: Adding test to concat Sparse arrays (#30645)
1 parent 7796be6 commit 8cff0e1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/reshape/test_concat.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
read_csv,
2929
)
3030
import pandas._testing as tm
31+
from pandas.core.arrays import SparseArray
3132
from pandas.core.construction import create_series_with_explicit_dtype
3233
from pandas.tests.extension.decimal import to_decimal
3334

@@ -2739,3 +2740,13 @@ def test_concat_empty_df_object_dtype():
27392740
result = pd.concat([df_1, df_2], axis=0)
27402741
expected = df_1.astype(object)
27412742
tm.assert_frame_equal(result, expected)
2743+
2744+
2745+
def test_concat_sparse():
2746+
# GH 23557
2747+
a = pd.Series(SparseArray([0, 1, 2]))
2748+
expected = pd.DataFrame(data=[[0, 0], [1, 1], [2, 2]]).astype(
2749+
pd.SparseDtype(np.int64, 0)
2750+
)
2751+
result = pd.concat([a, a], axis=1)
2752+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)