25
25
ABCIndexClass ,
26
26
ABCPeriodIndex ,
27
27
ABCRangeIndex ,
28
- ABCSparseDataFrame ,
29
28
ABCTimedeltaIndex ,
30
29
)
31
30
@@ -71,41 +70,7 @@ def get_dtype_kinds(l):
71
70
return typs
72
71
73
72
74
- def _get_series_result_type (result , objs = None ):
75
- """
76
- return appropriate class of Series concat
77
- input is either dict or array-like
78
- """
79
- from pandas import SparseSeries , SparseDataFrame , DataFrame
80
-
81
- # concat Series with axis 1
82
- if isinstance (result , dict ):
83
- # concat Series with axis 1
84
- if all (isinstance (c , (SparseSeries , SparseDataFrame )) for c in result .values ()):
85
- return SparseDataFrame
86
- else :
87
- return DataFrame
88
-
89
- # otherwise it is a SingleBlockManager (axis = 0)
90
- return objs [0 ]._constructor
91
-
92
-
93
- def _get_frame_result_type (result , objs ):
94
- """
95
- return appropriate class of DataFrame-like concat
96
- if all blocks are sparse, return SparseDataFrame
97
- otherwise, return 1st obj
98
- """
99
-
100
- if result .blocks and (any (isinstance (obj , ABCSparseDataFrame ) for obj in objs )):
101
- from pandas .core .sparse .api import SparseDataFrame
102
-
103
- return SparseDataFrame
104
- else :
105
- return next (obj for obj in objs if not isinstance (obj , ABCSparseDataFrame ))
106
-
107
-
108
- def _concat_compat (to_concat , axis = 0 ):
73
+ def concat_compat (to_concat , axis = 0 ):
109
74
"""
110
75
provide concatenation of an array of arrays each of which is a single
111
76
'normalized' dtypes (in that for example, if it's object, then it is a
@@ -142,12 +107,12 @@ def is_nonempty(x):
142
107
_contains_period = any (typ .startswith ("period" ) for typ in typs )
143
108
144
109
if "category" in typs :
145
- # this must be prior to _concat_datetime ,
110
+ # this must be prior to concat_datetime ,
146
111
# to support Categorical + datetime-like
147
- return _concat_categorical (to_concat , axis = axis )
112
+ return concat_categorical (to_concat , axis = axis )
148
113
149
114
elif _contains_datetime or "timedelta" in typs or _contains_period :
150
- return _concat_datetime (to_concat , axis = axis , typs = typs )
115
+ return concat_datetime (to_concat , axis = axis , typs = typs )
151
116
152
117
# these are mandated to handle empties as well
153
118
elif "sparse" in typs :
@@ -174,7 +139,7 @@ def is_nonempty(x):
174
139
return np .concatenate (to_concat , axis = axis )
175
140
176
141
177
- def _concat_categorical (to_concat , axis = 0 ):
142
+ def concat_categorical (to_concat , axis = 0 ):
178
143
"""Concatenate an object/categorical array of arrays, each of which is a
179
144
single dtype
180
145
@@ -214,7 +179,7 @@ def _concat_categorical(to_concat, axis=0):
214
179
else np .asarray (x .astype (object ))
215
180
for x in to_concat
216
181
]
217
- result = _concat_compat (to_concat )
182
+ result = concat_compat (to_concat )
218
183
if axis == 1 :
219
184
result = result .reshape (1 , len (result ))
220
185
return result
@@ -400,7 +365,7 @@ def _concatenate_2d(to_concat, axis):
400
365
return np .concatenate (to_concat , axis = axis )
401
366
402
367
403
- def _concat_datetime (to_concat , axis = 0 , typs = None ):
368
+ def concat_datetime (to_concat , axis = 0 , typs = None ):
404
369
"""
405
370
provide concatenation of an datetimelike array of arrays each of which is a
406
371
single M8[ns], datetimet64[ns, tz] or m8[ns] dtype
0 commit comments