diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-10-30 10:58:49 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-10-30 10:59:11 +0100 |
commit | 2ad72b84363f9652439c90ecdb013a75497ee72a (patch) | |
tree | 0e955124ec24606b94580a55fd43120928c41dae /src | |
parent | 4d6b938a4b243873e1bcd9fcb48e487d8507ac43 (diff) | |
download | ee-python-2ad72b84363f9652439c90ecdb013a75497ee72a.tar.gz ee-python-2ad72b84363f9652439c90ecdb013a75497ee72a.tar.bz2 ee-python-2ad72b84363f9652439c90ecdb013a75497ee72a.tar.xz ee-python-2ad72b84363f9652439c90ecdb013a75497ee72a.zip |
o Replace all NaN values with None values when converting kicad object to a DataFrame.
Diffstat (limited to 'src')
-rw-r--r-- | src/ee/kicad/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ee/kicad/__init__.py b/src/ee/kicad/__init__.py index 1261cb5..d89c209 100644 --- a/src/ee/kicad/__init__.py +++ b/src/ee/kicad/__init__.py @@ -20,6 +20,7 @@ __all__ = [ def to_pandas(obj: Any, **kwarg): import pandas + import numpy as np def run_filter(filters, obj): for f in filters: @@ -63,9 +64,11 @@ def to_pandas(obj: Any, **kwarg): columns = set([key for row in data for key in list(row)]) - set(special_fields) columns = special_fields + list(columns) - return pandas.DataFrame(data=data, columns=columns). \ + df = pandas.DataFrame(data=data, columns=columns). \ set_index("ref"). \ - sort_values(["ref_type", "ref_num"]) + sort_values(["ref_type", "ref_num"]). \ + applymap(lambda s: s if isinstance(s, str) else None) + return df if isinstance(obj, Schematic): return to_pandas_schematic(obj) |