File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -8939,7 +8939,11 @@ def explode(
8939
8939
3 4 1 e
8940
8940
"""
8941
8941
if not self .columns .is_unique :
8942
- raise ValueError ("columns must be unique" )
8942
+ duplicate_cols = self .columns [self .columns .duplicated ()].tolist ()
8943
+ raise ValueError (
8944
+ "data frame columns must be unique. "
8945
+ + f"Duplicate columns: { duplicate_cols } "
8946
+ )
8943
8947
8944
8948
columns : list [Hashable ]
8945
8949
if is_scalar (column ) or isinstance (column , tuple ):
Original file line number Diff line number Diff line change
1
+ import re
2
+
1
3
import numpy as np
2
4
import pytest
3
5
@@ -18,7 +20,10 @@ def test_error():
18
20
df .explode (list ("AA" ))
19
21
20
22
df .columns = list ("AA" )
21
- with pytest .raises (ValueError , match = "columns must be unique" ):
23
+ with pytest .raises (
24
+ ValueError ,
25
+ match = re .escape ("data frame columns must be unique. Duplicate columns: ['A']" ),
26
+ ):
22
27
df .explode ("A" )
23
28
24
29
You can’t perform that action at this time.
0 commit comments