Skip to content

Commit b8f2634

Browse files
committed
BUG: fix dirint KeyError with scalar inputs on pandas >= 2.0
1 parent 603ede0 commit b8f2634

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pvlib/irradiance.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,14 @@ def _dirint_bins(times, kt_prime, zenith, w, delta_kt_prime):
21092109
-------
21102110
tuple of kt_prime_bin, zenith_bin, w_bin, delta_kt_prime_bin
21112111
"""
2112+
# Ensure scalar inputs are converted to Series so that boolean masks
2113+
# produce a boolean Series rather than a scalar bool.
2114+
# Scalar bools cause KeyError in pandas >= 2.0. GH #XXXX
2115+
kt_prime = pd.Series(kt_prime, index=times, dtype=float)
2116+
zenith = pd.Series(zenith, index=times, dtype=float)
2117+
w = pd.Series(w, index=times, dtype=float)
2118+
delta_kt_prime = pd.Series(delta_kt_prime, index=times, dtype=float)
2119+
21122120
# @wholmgren: the following bin assignments use MATLAB's 1-indexing.
21132121
# Later, we'll subtract 1 to conform to Python's 0-indexing.
21142122

0 commit comments

Comments
 (0)