Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit cea43d8

Browse files
committed
Fix #80
1 parent f8316e0 commit cea43d8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

root_pandas/readwrite.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
A module that extends pandas to support the ROOT data format.
44
"""
5+
from collections import Counter
56

67
import numpy as np
78
from numpy.lib.recfunctions import append_fields
@@ -366,6 +367,11 @@ def to_root(df, path, key='my_ttree', mode='w', store_index=True, *args, **kwarg
366367
else:
367368
raise ValueError('Unknown mode: {}. Must be "a" or "w".'.format(mode))
368369

370+
column_name_counts = Counter(df.columns)
371+
if max(column_name_counts.values()) > 1:
372+
raise ValueError('DataFrame contains duplicated column names: ' +
373+
' '.join({k for k, v in column_name_counts.items() if v > 1}))
374+
369375
from root_numpy import array2tree
370376
# We don't want to modify the user's DataFrame here, so we make a shallow copy
371377
df_ = df.copy(deep=False)

0 commit comments

Comments
 (0)