Skip to content

Conversation

@staskh
Copy link
Owner

@staskh staskh commented Sep 10, 2025

Problem

Users with pandas 1.5.3 are experiencing errors when using IGLU-Python functions:

TypeError: auc_single() got an unexpected keyword argument 'include_groups'

Root Cause

The include_groups parameter was introduced in pandas 2.0.0, but many users still have pandas 1.5.3 installed. This parameter doesn't exist in older pandas versions, causing the error.

Solution

This PR fixes compatibility by:

  1. Removing all include_groups=False parameters from groupby().apply() calls
  2. Adding explicit column selection to prevent deprecation warnings
  3. Maintaining identical functionality across pandas versions

Changes Made

Files Modified

  • iglu_python/auc.py - Fixed 2 groupby operations
  • iglu_python/grade.py - Fixed 1 groupby operation
  • iglu_python/episode_calculation.py - Fixed 3 groupby operations
  • pyproject.toml - Version bump to 0.3.1

Technical Details

  • Before: data.groupby('id').apply(lambda x: ..., include_groups=False)
  • After: data.groupby('id')[['gl']].apply(lambda x: ...)

Compatibility Matrix

Pandas Version Status Behavior
1.5.3 ✅ Works Excludes grouping columns (default)
2.0+ ✅ Works Excludes grouping columns (explicit)

Testing

✅ All functions tested and working:

  • iglu.auc() - AUC calculation
  • iglu.grade() - GRADE score calculation
  • iglu.episode_calculation() - Episode analysis

Impact

  • No breaking changes - API remains identical
  • No performance impact - Explicit column selection improves efficiency
  • Wider compatibility - Works with pandas 1.5.3 through 2.2.3+
  • Future-proof - Prevents deprecation warnings

This fix ensures IGLU-Python works seamlessly across different pandas versions without requiring users to upgrade their pandas installation.

- Remove include_groups parameter from all groupby().apply() calls
- Add explicit column selection to prevent deprecation warnings
- Update AUC function to work with pandas 1.5.3
- Update GRADE function to work with pandas 1.5.3
- Update episode_calculation function to work with pandas 1.5.3
- Bump version to 0.3.1

The include_groups parameter was introduced in pandas 2.0.0, causing
'unexpected keyword argument' errors in pandas 1.5.3. This fix:

1. Removes all include_groups=False parameters
2. Adds explicit column selection [['gl', 'gl_next']] to groupby operations
3. Maintains same functionality while ensuring compatibility

All functions now work correctly with pandas 1.5.3:
- iglu.auc() - AUC calculation
- iglu.grade() - GRADE score calculation
- iglu.episode_calculation() - Episode analysis

Resolves compatibility issues for users with older pandas versions.
@staskh staskh merged commit a585c43 into main Sep 10, 2025
3 checks passed
@staskh staskh deleted the fix-pandas-1.5.3-compatibility branch September 10, 2025 18:24
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.16%. Comparing base (8932308) to head (ec925d1).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
iglu_python/auc.py 50.00% 1 Missing ⚠️
iglu_python/episode_calculation.py 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #12   +/-   ##
=======================================
  Coverage   91.16%   91.16%           
=======================================
  Files          46       46           
  Lines        1754     1754           
=======================================
  Hits         1599     1599           
  Misses        155      155           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@staskh staskh restored the fix-pandas-1.5.3-compatibility branch September 14, 2025 08:33
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.

3 participants