-
Notifications
You must be signed in to change notification settings - Fork 30
Pandas version 2 support #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…patibility with pandas >=1.3.5
|
|
||
| # 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
| infernal["sframe"] = infernal["sframe"].replace(["-", "+"], [-1, 1]) | ||
| infernal["sframe"] = infernal["sframe"].replace({"-": "-1", "+": "1"}).astype("int16") |
There was a problem hiding this comment.
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.
| # 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) |
There was a problem hiding this comment.
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.
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.