From 2ad72b84363f9652439c90ecdb013a75497ee72a Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 30 Oct 2017 10:58:49 +0100 Subject: o Replace all NaN values with None values when converting kicad object to a DataFrame. --- src/ee/kicad/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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) -- cgit v1.2.3