Skip to content

Commit

Permalink
Merge pull request #380 from chezou/to_numeric
Browse files Browse the repository at this point in the history
Suppress pandas FutureWarning of to_numeric with errors='ignore'
  • Loading branch information
chezou authored Mar 16, 2024
2 parents 235e25c + 301da37 commit 3861295
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 3861295

Please sign in to comment.