Skip to content

BUG: Handle concat of series with same name, GH2972 #3058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pandas/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,10 @@ def get_result(self):
name = com._consensus_name_attr(self.objs)
return Series(new_data, index=self.new_axes[0], name=name)
elif self._is_series:
data = dict(zip(self.new_axes[1], self.objs))
return DataFrame(data, index=self.new_axes[0],
columns=self.new_axes[1])
data = dict(itertools.izip(xrange(len(self.objs)), self.objs))
tmpdf = DataFrame(data, index=self.new_axes[0])
tmpdf.columns = self.new_axes[1]
return tmpdf
else:
new_data = self._get_concatenated_data()
return self.objs[0]._from_axes(new_data, self.new_axes)
Expand Down
10 changes: 10 additions & 0 deletions pandas/tools/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,16 @@ def test_concat_bug_1719(self):

self.assertEqual(len(left), len(right))

def test_concat_bug_2972(self):
ts0 = Series(np.zeros(5))
ts1 = Series(np.ones(5))
ts0.name = ts1.name = 'same name'
result = concat([ts0, ts1], axis=1)

expected = DataFrame({0: ts0, 1: ts1})
expected.columns=['same name', 'same name']
assert_frame_equal(result, expected)


class TestOrderedMerge(unittest.TestCase):

Expand Down