Skip to content

Commit

Permalink
Be more careful about identifying pd.DataFrame. (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Nov 30, 2021
1 parent 624b033 commit 8ae497a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/uproot/writing/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ def add_to_directory(obj, name, directory, streamers):
if isinstance(obj, Mapping) and all(uproot._util.isstr(x) for x in obj):
data = {}
metadata = {}

for branch_name, branch_array in obj.items():
module_name = type(branch_array).__module__

if module_name == "pandas" or module_name.startswith("pandas."):
branch_array = uproot.writing._cascadetree.dataframe_to_dict(
branch_array
)
import pandas

if isinstance(branch_array, pandas.DataFrame):
branch_array = uproot.writing._cascadetree.dataframe_to_dict(
branch_array
)

if (
isinstance(branch_array, numpy.ndarray)
Expand Down

0 comments on commit 8ae497a

Please sign in to comment.