pytrends icon indicating copy to clipboard operation
pytrends copied to clipboard

Fix interest_over_time warning

Open danaiamirali opened this issue 6 months ago • 0 comments

With pandas==2.2.0, running an interest_over_time() request (a specific one is shown below) leads to the following FutureWarning error from pandas:

from pytrends.request import TrendReq

pytrend = TrendReq(hl='en-US', tz=360)

kw_list = ["D23"]

pytrend.build_payload(kw_list, timeframe='now 1-H')

interest_over_time_df = pytrend.interest_over_time()

print(interest_over_time_df)

C:\Documents\GitHub\Projects\pytrends\pytrends\request.py:266: 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) df = df.fillna(False)

This PR fixes the appearance of this warning with a one line addition.

danaiamirali avatar Aug 10 '24 16:08 danaiamirali