File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ pandas 0.10.0
235
235
- DataFrame.combine_first will always result in the union of the index and
236
236
columns, even if one DataFrame is length-zero (GH2525 _)
237
237
- Fix several DataFrame.icol/irow with duplicate indices issues (GH2228 _, GH2259 _)
238
+ - Use Series names for column names when using concat with axis=1 (GH2489 _)
238
239
239
240
.. _GH407 : https://github.com/pydata/pandas/issues/407
240
241
.. _GH821 : https://github.com/pydata/pandas/issues/821
@@ -353,6 +354,7 @@ pandas 0.10.0
353
354
.. _GH2525 : https://github.com/pydata/pandas/issues/2525
354
355
.. _GH2228 : https://github.com/pydata/pandas/issues/2228
355
356
.. _GH2259 : https://github.com/pydata/pandas/issues/2259
357
+ .. _GH2489 : https://github.com/pydata/pandas/issues/2489
356
358
357
359
358
360
pandas 0.9.1
Original file line number Diff line number Diff line change @@ -1140,7 +1140,13 @@ def _get_concat_axis(self):
1140
1140
if self .axis == 0 :
1141
1141
indexes = [x .index for x in self .objs ]
1142
1142
elif self .keys is None :
1143
- return Index (np .arange (len (self .objs )))
1143
+ names = []
1144
+ for x in self .objs :
1145
+ if x .name is not None :
1146
+ names .append (x .name )
1147
+ else :
1148
+ return Index (np .arange (len (self .objs )))
1149
+ return Index (names )
1144
1150
else :
1145
1151
return _ensure_index (self .keys )
1146
1152
else :
Original file line number Diff line number Diff line change @@ -1497,6 +1497,18 @@ def test_concat_series_axis1(self):
1497
1497
expected = DataFrame (pieces , index = ['A' , 'B' , 'C' ]).T
1498
1498
assert_frame_equal (result , expected )
1499
1499
1500
+ # preserve series names, #2489
1501
+ s = Series (randn (5 ), name = 'A' )
1502
+ s2 = Series (randn (5 ), name = 'B' )
1503
+
1504
+ result = concat ([s , s2 ], axis = 1 )
1505
+ expected = DataFrame ({'A' : s , 'B' : s2 })
1506
+ assert_frame_equal (result , expected )
1507
+
1508
+ s2 .name = None
1509
+ result = concat ([s , s2 ], axis = 1 )
1510
+ self .assertTrue (np .array_equal (result .columns , range (2 )))
1511
+
1500
1512
def test_concat_single_with_key (self ):
1501
1513
df = DataFrame (np .random .randn (10 , 4 ))
1502
1514
You can’t perform that action at this time.
0 commit comments