Skip to content

Commit

Permalink
Update to_numeric, georoc
Browse files Browse the repository at this point in the history
  • Loading branch information
morganjwilliams committed Jul 24, 2018
1 parent ea3aa78 commit 559faed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pyrolite/util/georoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import re
import logging

from pyrolite.util.text import titlecase

logging.getLogger(__name__).addHandler(logging.NullHandler())
logger = logging.getLogger(__name__)

Expand Down
8 changes: 5 additions & 3 deletions pyrolite/util/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ def to_numeric(df: pd.DataFrame,
"""
Takes all non-metadata columns and converts to numeric type where possible.
"""
num_headers = [i for i in df.columns.unique() if i not in exclude]
for c in num_headers:
df.loc[:, c] = pd.to_numeric(df.loc[:, c], errors=errors)
numeric_headers = [i for i in df.columns.unique() if i not in exclude]
# won't work with .loc on LHS
# https://stackoverflow.com/a/46629514
df[numeric_headers] = df[numeric_headers].apply(pd.to_numeric,
errors=errors)
return df


Expand Down

0 comments on commit 559faed

Please sign in to comment.