yahooquery
yahooquery copied to clipboard
Fix FutureWarnings for Pandas Compatibility and Chained Assignment
Changes Made:
-
Pandas Timedelta Deprecation Warning:
- Updated the use of
"S"to"s"inpd.Timedeltato conform to the upcoming deprecation in pandas. This change fixes the FutureWarning regarding the deprecation of'S'in favor of's'for specifying seconds inpd.Timedelta.
# Before: has_live_indice = index_utc[-1] >= last_trade - pd.Timedelta(2, "S") # After: has_live_indice = index_utc[-1] >= last_trade - pd.Timedelta(2, "s") - Updated the use of
-
Chained Assignment Warning:
- Altered the approach to setting values in the DataFrame to avoid chained assignment, which is not recommended due to its unclear behavior in certain contexts (operations that behave as if they were on a copy.). This adjustment is in response to pandas' future change in how
inplace=Truewill function.
# Before: df["dividends"].fillna(0, inplace=True) - Altered the approach to setting values in the DataFrame to avoid chained assignment, which is not recommended due to its unclear behavior in certain contexts (operations that behave as if they were on a copy.). This adjustment is in response to pandas' future change in how
... df["splits"].fillna(0, inplace=True)
After:
df["dividends"] = df["dividends"].fillna(0) ... df["splits"] = df["splits"].fillna(0)
I believe this is a duplicate of #262, only difference being that this overwrites the 'dividends' and 'split' columns as opposed to undertaking the fillna operation in place. Changes in #262 are in line with the advices offered in the deprecation warning, although seems this PR would also do the trick.