Skip to content
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

Suppress pandas FutureWarning of to_numeric with errors='ignore' #380

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def lint(session):
("3.10", True),
("3.11", True),
("3.12", False),
("3.12", True),
],
)
def tests(session, jpype):
Expand Down
7 changes: 6 additions & 1 deletion tabula/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,12 @@ def _extract_from(

if not pandas_options.get("dtype"):
for c in df.columns:
df[c] = pd.to_numeric(df[c], errors="ignore")
try:
df[c] = pd.to_numeric(df[c], errors="raise")
except (ValueError, TypeError):
# Same logic as errors='ignore' in pd.to_numeric
# https://github.com/pandas-dev/pandas/pull/57361/files#diff-08fed2587c15d0370931a8b02252eb1034d2c0a650df56760974440a5433a6e0L240-L243
pass
data_frames.append(df)

return data_frames
Expand Down
Loading