Skip to content

Fix pandas 2.x API drift in top_network_plot helpers - #390

Open
marouenbg wants to merge 2 commits into
netZoo:masterfrom
marouenbg:fix-pandas2-api
Open

Fix pandas 2.x API drift in top_network_plot helpers#390
marouenbg wants to merge 2 commits into
netZoo:masterfrom
marouenbg:fix-pandas2-api

Conversation

@marouenbg

Copy link
Copy Markdown
Contributor

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 to axis=1 (4 call sites in panda.py, analyze_panda.py, puma.py).
  • self.export_panda_results[['force']] = series raises ValueError: Columns must be same length as key in pandas 2.x — change to scalar ["force"] = ... in AnalyzeLioness.top_network_plot.

Test plan

  • panda_obj.top_network_plot(top=10, file="...") runs without TypeError (verified via netbooks/netZooPy/Up_and_running_with_PANDA_and_netZooPy.ipynb)
  • analyze_lioness_obj.top_network_plot(top=10, file="...") runs (verified via netbooks/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

marouenbg and others added 2 commits May 13, 2026 00:00
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

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.54%. Comparing base (0d48356) to head (31712f8).
⚠️ Report is 8 commits behind head on master.

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 Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@katehoffshutta katehoffshutta added the ai-contrib Some or all of this code is written by AI and requires a human review. label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-contrib Some or all of this code is written by AI and requires a human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants