77from pandas .core .internals import (
88 Block , BlockManager , SingleBlockManager , NonConsolidatableMixIn )
99
10+ import pytest
11+
1012
1113class CustomBlock (NonConsolidatableMixIn , Block ):
1214
@@ -25,6 +27,17 @@ def concat_same_type(self, to_concat, placement=None):
2527 values , placement = placement or slice (0 , len (values ), 1 ))
2628
2729
30+ @pytest .fixture
31+ def df ():
32+ df1 = pd .DataFrame ({'a' : [1 , 2 , 3 ]})
33+ blocks = df1 ._data .blocks
34+ values = np .arange (3 , dtype = 'int64' )
35+ custom_block = CustomBlock (values , placement = slice (1 , 2 ))
36+ blocks = blocks + (custom_block ,)
37+ block_manager = BlockManager (blocks , [pd .Index (['a' , 'b' ]), df1 .index ])
38+ return pd .DataFrame (block_manager )
39+
40+
2841def test_custom_repr ():
2942 values = np .arange (3 , dtype = 'int64' )
3043
@@ -51,14 +64,14 @@ def test_concat_series():
5164 assert isinstance (res ._data .blocks [0 ], CustomBlock )
5265
5366
54- def test_concat_dataframe ():
67+ def test_concat_dataframe (df ):
5568 # GH17728
56- df = pd .DataFrame ({'a' : [1 , 2 , 3 ]})
57- blocks = df ._data .blocks
58- values = np .arange (3 , dtype = 'int64' )
59- custom_block = CustomBlock (values , placement = slice (1 , 2 ))
60- blocks = blocks + (custom_block , )
61- block_manager = BlockManager (blocks , [pd .Index (['a' , 'b' ]), df .index ])
62- df = pd .DataFrame (block_manager )
6369 res = pd .concat ([df , df ])
6470 assert isinstance (res ._data .blocks [1 ], CustomBlock )
71+
72+
73+ def test_concat_axis1 (df ):
74+ # GH17954
75+ df2 = pd .DataFrame ({'c' : [.1 , .2 , .3 ]})
76+ res = pd .concat ([df , df2 ], axis = 1 )
77+ assert isinstance (res ._data .blocks [1 ], CustomBlock )
0 commit comments