Skip to content

Commit

Permalink
fix: adjust for Pandas changing its API again (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Nov 7, 2024
1 parent f15cb17 commit 8ca7f15
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/uproot/interpretation/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,12 @@ def global_index(self, arrays, global_offset):
)

else:
index = arrays.index.arrays
# arrays.index.values before Pandas 0.24 and again now;
# arrays.index.arrays from Pandas 0.24 through some time ago.
if hasattr(arrays.index, "values"):
index = arrays.index.values
else:
index = arrays.index.arrays
numpy.add(index, global_offset, out=index)

return arrays
Expand Down
20 changes: 20 additions & 0 deletions tests/test_1321_pandas_changed_api_again.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE

import pytest
import skhep_testdata
import uproot

pytest.importorskip("pandas")


def test():
assert (
len(
uproot.concatenate(
skhep_testdata.data_path("uproot-Zmumu.root"),
library="pd",
cut="Run > 148029",
)
)
== 1580
)

0 comments on commit 8ca7f15

Please sign in to comment.