Skip to content

Conversation

@varshithreddy39
Copy link

This PR fixes a pandas FutureWarning triggered in table_to_frame
when handling discrete variables by following pandas'
recommended infer_objects(copy=False) usage.

Closes #7063.

@CLAassistant
Copy link

CLAassistant commented Dec 27, 2025

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.03%. Comparing base (3a5a802) to head (b4c6524).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7222      +/-   ##
==========================================
- Coverage   89.03%   89.03%   -0.01%     
==========================================
  Files         335      335              
  Lines       74243    74243              
==========================================
- Hits        66102    66101       -1     
- Misses       8141     8142       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@varshithreddy39
Copy link
Author

Thanks for the update!

I see that one CI check is failing on macOS (py3.12).
Please let me know if this failure is related to my changes or if there’s anything I should fix on my side.

Happy to update the PR if needed.

@janezd
Copy link
Contributor

janezd commented Dec 27, 2025

@varshithreddy39 , thank you for this PR.

The failing test doesn't look related to your changes. I haven't seen this failure yet; we'll see whether it reappears on the next run.

The proposed fix doesn't work, though. The warning still shows in this place and in one other (see the logs below).

My experience with pandas is inadequate, but I think that the problem is before fillna, not after. I'm not sure, but I think that the correct order is

            codes = pd.Series(vals).infer_objects(copy=False).fillna(-1).astype(int)

This removes the warning and doesn't seem to break anything.

Please do the following.

  • Try the above line. Another case is in line 279 (with astype(str))
  • Please leave astype, and remove the extra parentheses.
  • Make sure you run all three tests where this warning appears (test_aggregate.DomainTest.test_preserve_variables, test_pandas_compat.TestPandasCompat.test_table_from_frame_no_datetime,
    Orange.widgets.data.tests.test_owgroupby.TestOWGroupBy.test_time_variable_results)
  • You can also change the title. The one in the PR that you closed was better. :)

Thanks again!

2025-12-27T08:55:07.0305623Z test_preserve_variables (test_aggregate.DomainTest.test_preserve_variables) ... D:\a\orange3\orange3\.tox\orange-latest\Lib\site-packages\Orange\data\pandas_compat.py:279: 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)`
2025-12-27T08:55:07.0308451Z   s.astype(object).fillna(StringVariable.Unknown).astype(str),
2025-12-27T08:55:07.0520561Z D:\a\orange3\orange3\.tox\orange-latest\Lib\site-packages\Orange\data\pandas_compat.py:279: 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)`
2025-12-27T08:55:07.0523351Z   s.astype(object).fillna(StringVariable.Unknown).astype(str),

2025-12-27T08:55:07.2612763Z test_table_from_frame_no_datetime (test_pandas_compat.TestPandasCompat.test_table_from_frame_no_datetime)
2025-12-27T08:55:07.2725387Z In case when dtype of column is object and column contains numbers only, ... D:\a\orange3\orange3\.tox\orange-latest\Lib\site-packages\Orange\data\pandas_compat.py:279: 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)`
2025-12-27T08:55:07.2728916Z   s.astype(object).fillna(StringVariable.Unknown).astype(str),

2025-12-27T08:56:19.7831609Z test_time_variable_results (Orange.widgets.data.tests.test_owgroupby.TestOWGroupBy.test_time_variable_results) ... D:\a\orange3\orange3\.tox\orange-latest\Lib\site-packages\Orange\data\pandas_compat.py:474: 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)`
2025-12-27T08:56:19.7834695Z   codes = (pd.Series(vals).fillna(-1).infer_objects(copy=False).astype(int))
2025-12-27T08:56:19.7940457Z ok
2025-12-27T08:56:19.7945622Z test_tz_time_variable_results (Orange.widgets.data.tests.test_owgroupby.TestOWGroupBy.test_tz_time_variable_results)
2025-12-27T08:56:19.9530206Z Test results in case of timezoned time variable ... D:\a\orange3\orange3\.tox\orange-latest\Lib\site-packages\Orange\data\pandas_compat.py:474: 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)`
2025-12-27T08:56:19.9532180Z   codes = (pd.Series(vals).fillna(-1).infer_objects(copy=False).astype(int))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FutureWarning when using table_to_frame

3 participants