Skip to content

Commit 21d526a

Browse files
committed
TST: Add test for mangling of unnamed columns
xref gh-13017.
1 parent d78bd7a commit 21d526a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/io/parser/mangle_dupes.py

+16
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,19 @@ def test_thorough_mangle_names(self):
8686
mangle_dupe_cols=True)
8787
assert list(df.columns) == ["a", "a.1", "a.3", "a.1.1",
8888
"a.2", "a.2.1", "a.3.1"]
89+
90+
def test_mangled_unnamed_placeholders(self):
91+
# xref gh-13017
92+
orig_data = {"0": [1, 2, 3]}
93+
df = DataFrame(orig_data)
94+
95+
# This test recursively updates `df`.
96+
for i in range(3):
97+
exp_data = {"Unnamed: 0" + ".1" * j: [0, 1, 2]
98+
for j in range(i + 1)}
99+
exp_data.update(orig_data)
100+
101+
expected = DataFrame(exp_data)
102+
df = self.read_csv(StringIO(df.to_csv()))
103+
104+
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)