Skip to content

BUG: pd.options.future.no_silent_downcasting is not backward compatible #59845

Open
@vityas

Description

@vityas

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

with pd.option_context('future.no_silent_downcasting', True):
  pd.Series([None]).fillna(False)

Issue Description

I was not able to find a code that doesn't throw warnings for pandas >= 2.0. The example will work in pandas 2.2, but will break for earlier versions. Ahem... This is probably the first time in my Python development that a backwards incompatible change has been issued with a backwards incompatible workaround.

Expected Behavior

Not throw any warning.

i could do something like this

if pandas.__version__ >= '2.2.0':
  with pd.option_context('future.no_silent_downcasting', True):
    pd.Series([None]).fillna(False)
else:
  pd.Series([None]).fillna(False)

I suppose this code would work, but it's a bad code.

Installed Versions

pandas : 2.2.2
numpy : 1.26.3
pytz : 2024.1
dateutil : 2.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds InfoClarification about behavior needed to assess issuePDEP6-relatedrelated to PDEP6 (not upcasting during setitem-like Series operations)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions