Skip to content

Replace deprecated pandas and geopandas API calls#80

Open
arpitjain099 wants to merge 2 commits into
dbetchkal:mainfrom
arpitjain099:fix/deprecated-api-calls
Open

Replace deprecated pandas and geopandas API calls#80
arpitjain099 wants to merge 2 commits into
dbetchkal:mainfrom
arpitjain099:fix/deprecated-api-calls

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Fixes a few deprecated API calls that currently emit warnings and will break on newer versions of pandas and geopandas.

Changes:

  • delim_whitespace=True replaced with sep=r'\s+' in pd.read_csv() calls. The delim_whitespace parameter was deprecated in pandas 2.2 and will be removed in a future version. Both in active_space_generator.py and the legacy active_space_utils.py.

  • op='within' replaced with predicate='within' in gpd.sjoin(). The op parameter was renamed to predicate in geopandas 0.10 and has been raising deprecation warnings since.

  • DataFrame.append() replaced with pd.concat() in generate_active_space_mesh.py. The .append() method was removed entirely in pandas 2.0.

These are all drop-in replacements with identical behavior, just using the current API names. Should help when upgrading to newer pandas/geopandas releases down the road.

- Replace `delim_whitespace=True` with `sep=r'\s+'` in pd.read_csv calls
  (deprecated since pandas 2.2)
- Replace `op='within'` with `predicate='within'` in gpd.sjoin
  (deprecated since geopandas 0.10)
- Replace DataFrame.append() with pd.concat()
  (removed in pandas 2.0)

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099

Copy link
Copy Markdown
Contributor Author

@dbetchkal please also review this PR as it makes the code future proof.

@elliott-ruebush elliott-ruebush left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we easily add some unit testing / include some verification that behavior is identical to this PR? (I trust it is, but would be nice to add unit tests as we touch different parts of the codebase if testing is straightforward)

@arpitjain099

Copy link
Copy Markdown
Contributor Author

Good call. The replacements are all 1:1 behavioral equivalents (sjoin predicate= instead of op=, concat instead of append, etc) but having tests to confirm that is worth doing. I'll push those.

Unit tests covering the three API migrations:
- pd.read_csv sep=r'\s+' replacing delim_whitespace=True
- pd.concat replacing DataFrame.append
- gpd.sjoin predicate= replacing op=

Each test class uses self-contained data and verifies the new calls
produce correct results matching the old behavior.

Signed-off-by: arpitjain099 <arpitjain099@gmail.com>

@elliott-ruebush elliott-ruebush Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies as I was unclear in my previous comment. Ideally, we would test the behavior that utilizes this pandas/geopandas functionality rather than the library functionality itself. I realize that the behavior in the active space generation may be complex and difficult to unit test cleanly in its current state though.

For the sjoin and ConcatReplacesAppend tests, I'm not sure how much additional value those provide in their current form.

If what I'm getting at is unclear, let me know and happy to explain more or call briefly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. You're right that testing sjoin and concat in isolation doesn't add much beyond confirming pandas works. I'll drop the ConcatReplacesAppend and sjoin-specific tests and replace them with something that exercises the actual downstream behavior (e.g. a small GeoDataFrame going through the spatial join logic in helpers or the track merging path). Will push an update.

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.

2 participants