How do I correctly apply Pandas' 'infer_objects' function?
I try the following example in Pandas 2.2.3:
outage_mask = pd.Series(([True]*5 + [False]*5)*5, index=pd.date_range("2025-01-01", freq="1h", periods=50)) [ts for ts in outage_mask.loc[outage_mask.diff().fillna(False)].index]
This gives me a warning about downcasting object dtype arrays on 'fillna'. I cannot figure out how to apply the suggested 'infer_objects' correctly 🤔
https://stackoverflow.com/q/79383833/865169
=> More informations about this toot | More toots from arildsen@fosstodon.org
This answer on SO was helpful: https://stackoverflow.com/a/79383870/865169
Use convert_dtypes
on the output of diff
. This converts the Series to Pandas boolean, which is nullable and can contain the NaNs - problem solved.
It does not tell me how to correctly use infer_objects
, but luckily I will not have to deal with that for now.
=> More informations about this toot | More toots from arildsen@fosstodon.org This content has been proxied by September (3851b).Proxy Information
text/gemini