Fix pandas 2.x API drift in top_network_plot helpers#390
Open
marouenbg wants to merge 2 commits into
Open
Conversation
Two pandas API breaks were hitting top_network_plot() across panda, analyze_panda, lioness/analyze_lioness, and puma: 1. `DataFrame.drop(labels, 1)` — pandas 2.x requires `axis=1` as a keyword argument; the bare positional form raises `TypeError: DataFrame.drop() takes from 1 to 2 positional arguments but 3 were given`. 2. `self.export_panda_results[['force']] = self.lioness_results.iloc[:, index+2]` in AnalyzeLioness.top_network_plot — assigning a single-column Series to a single-element column list now raises `ValueError: Columns must be same length as key`. Use scalar key `self.export_panda_results["force"] = ...` instead. These came up while running the netbooks tutorials end-to-end against a fresh pandas 2.x install (pv2 Building_single-sample_LIONESS, pv3 Up_and_running_with_PANDA). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cobra CI revealed two more sites breaking on the same pandas API change (Series integer subscript switching from positional to label-based): - netZooPy/condor/condor.py:308 in matrices(): `edge[1][N]` over a row Series with labels ['V1', 'V2', 'weight'] raised KeyError: 2 because the integer key is now treated as a label. Use `.iloc[N]` to keep positional semantics. - tests/test_cobra.py: `np.mean(X, axis=0)[i]` on a Series with column- label index raised KeyError: 0 for the same reason. Switch to `.iloc[i]`. Verified both test_cobra and test_condor pass under pandas 2.3.x. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #390 +/- ##
==========================================
+ Coverage 59.42% 59.54% +0.11%
==========================================
Files 41 45 +4
Lines 2844 3055 +211
==========================================
+ Hits 1690 1819 +129
- Misses 1154 1236 +82 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two pandas 2.x API drifts in the panda/lioness/puma top-network plotters. Both surfaced while running the netbooks tutorials end-to-end against a current pandas install.
DataFrame.drop(labels, 1)no longer accepts the bare positional axis in pandas 2.x — switch toaxis=1(4 call sites inpanda.py,analyze_panda.py,puma.py).self.export_panda_results[['force']] = seriesraisesValueError: Columns must be same length as keyin pandas 2.x — change to scalar["force"] = ...inAnalyzeLioness.top_network_plot.Test plan
panda_obj.top_network_plot(top=10, file="...")runs withoutTypeError(verified vianetbooks/netZooPy/Up_and_running_with_PANDA_and_netZooPy.ipynb)analyze_lioness_obj.top_network_plot(top=10, file="...")runs (verified vianetbooks/netZooPy/Building_single-sample_regulatory_networks_using_LIONESS_and_netZooPy.ipynb)puma.top_network_plot()— same change pattern, not exercised by a netbook but kept consistent with panda🤖 Generated with Claude Code