windpowerlib icon indicating copy to clipboard operation
windpowerlib copied to clipboard

pandas warning in `data.get_turbine_types()`

Open mkaut opened this issue 1 year ago • 0 comments

Calling wpl.data.get_turbine_types() with pandas 2.2.3 throws the following warning at windpowerlib/data.py:103:

 FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`

This is caused by .fillna(False) in the following:

curves_df = pd.merge(
    p_curves_df, cp_curves_df, how="outer", sort=True
).fillna(False)

I am no developer, but I did some reading about the warning and this seems to be a clean (and possible the "correct") way to get rid of it:

with pd.option_context('future.no_silent_downcasting', True):
    curves_df = pd.merge(
        p_curves_df, cp_curves_df, how="outer", sort=True
    ).fillna(False).infer_objects()

mkaut avatar Sep 26 '24 08:09 mkaut