Skip to content

Conversation

@standage
Copy link
Contributor

@standage standage commented Nov 7, 2025

The PR makes a few marginal changes to unlock support for pandas version 2. I ensured that all changes were compatible with pandas 1.3.5, currently the minimal supported version.

Partially addresses #56.


# for some reason some int columns are behaving as floats -- this converts them
inDf = inDf.apply(pd.to_numeric, errors="ignore", downcast="integer")
inDf = inDf.apply(pd.to_numeric, errors="coerce", downcast="integer").fillna(inDf)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The errors="ignore" mode is deprecated in v2 and will be removed in v3. Its behavior can be replicated with "coerce" mode which inserts an NA in case of error, followed by filling NA values with the original dataframe.

df = df.merge(orient, on="Type", how="left")
df["Type"] = df["Type"].str.replace("_", " ")
df["has_orientation"] = df["has_orientation"].fillna(value=False).infer_objects()
df["has_orientation"] = df["has_orientation"].astype(bool).fillna(value=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A couple places now require a bit more explicit handling of data types.

Comment on lines -78 to +80
infernal["sframe"] = infernal["sframe"].replace(["-", "+"], [-1, 1])
infernal["sframe"] = infernal["sframe"].replace({"-": "-1", "+": "1"}).astype("int16")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A couple places now require a bit more explicit handling of data types.

Comment on lines -184 to +185
# adds a FeatureLocation object so it can be used in gbk construction
inDf["feat loc"] = inDf.apply(FeatureLocation_smart, axis=1)
if inDf.empty:
inDf = pd.DataFrame(columns=DF_COLS)
else:
# adds a FeatureLocation object so it can be used in gbk construction
inDf["feat loc"] = inDf.apply(FeatureLocation_smart, axis=1)
Copy link
Contributor Author

@standage standage Nov 7, 2025

Choose a reason for hiding this comment

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

The changes I made to this file were not necessary for pandas v2 support. I only encountered errors when I downgraded to pandas v1.3.5 for testing. But the updated code should work across all supported versions.

@standage standage mentioned this pull request Nov 7, 2025
2 tasks
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.

1 participant