@@ -177,8 +177,8 @@ def matching(reference, *args, **kwargs):
177
177
178
178
def temporal_collocation (reference , other , window , method = "nearest" ,
179
179
return_index = False , return_distance = False ,
180
- dropduplicates = False , dropna = False , flag = None ,
181
- use_invalid = False ):
180
+ dropduplicates = False , dropna = False , checkna = False ,
181
+ flag = None , use_invalid = False ):
182
182
"""
183
183
Temporally collocates values to reference.
184
184
@@ -218,7 +218,11 @@ def temporal_collocation(reference, other, window, method="nearest",
218
218
dropna : bool, optional
219
219
Whether to drop NaNs from the resulting dataframe (arising for example
220
220
from duplicates with ``duplicates_nan=True`` or from missing values).
221
- Default is ``False``
221
+ Default is ``False``.
222
+ checkna: bool, optional
223
+ Whether to check if only NaNs are returned (i.e. no match has been
224
+ found). If set to ``True``, raises a ``UserWarning`` in case no match
225
+ has been found. Default is ``False``.
222
226
flag : np.ndarray, str or None, optional
223
227
Flag column as array or name of the flag column in `other`. If this is
224
228
given, the column will be interpreted as validity indicator. Any
@@ -307,6 +311,9 @@ def collocate(df):
307
311
308
312
# postprocessing
309
313
# --------------
314
+ if checkna :
315
+ if np .any (collocated .isnull ().apply (np .all )):
316
+ warnings .warn ("No match has been found" )
310
317
if dropna :
311
318
collocated .dropna (inplace = True )
312
319
0 commit comments